Search found 8 matches

by gladiatorcn
Sat Jan 14, 2006 6:54 pm
Forum: Volume 1 (100-199)
Topic: 112 - Tree Summing
Replies: 137
Views: 32363

I got an AC. Here is my code: ( hope that it helps )

#include <iostream>
#include <stack>

using namespace std;

int main()
{
int n;
stack<int> s;

while(cin>>n)
{
bool yes=false;
bool lchild=false;
char c;
do{
cin>>c;
while(c==' '||c=='\t'||c=='\n') cin>>c;
if(c=='(')
{
//push
char ...
by gladiatorcn
Fri Dec 16, 2005 7:48 am
Forum: Volume 1 (100-199)
Topic: 106 - Fermat vs. Pythagoras
Replies: 138
Views: 30370

106 What is wrong?

Here is my source code. It computes the no of relatively prime triangles correctly, but gets wrong no of non-triangle numbers. I think my calculation is right, and the answer provided wrong?

#include <iostream>
#include <math.h>
#include <map>

using namespace std;

int common_divisor(int a,int b ...
by gladiatorcn
Wed Dec 14, 2005 11:15 am
Forum: Volume 1 (100-199)
Topic: 105 - The Skyline Problem
Replies: 160
Views: 51432

105 Presentation error

What is a presentation error?

#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

int main()
{
int space[10000], ans[10000];
ostream_iterator<int> outS(cout," ");

fill(space,space+10000,0);

int i,j,h;
while(cin>>i>>h>>j)
{
for(int p=i;p<j;p++)
{
if(h ...
by gladiatorcn
Sun Dec 11, 2005 3:10 pm
Forum: Volume 1 (100-199)
Topic: 102 - Ecological Bin Packing
Replies: 485
Views: 116782

my program passes all your cases but is still getting a WA. so sad :~

// 102
// Guo Fei
#include <iostream>

using namespace std;

int main()
{
char table[3] = {'B', 'C', 'G'};
int min;
int bin[3][3];
char solution[3];

while(cin>>bin[0][0]>>bin[0][2]>>bin[0][1]>>bin[1][0]>>bin[1][2]>>bin[1 ...
by gladiatorcn
Fri Apr 01, 2005 9:45 am
Forum: Volume 1 (100-199)
Topic: 103 - Stacking Boxes
Replies: 200
Views: 50407

103 WA????!!!!

My program s produced the correct answers to all the sample inputs, but got a wa. Plz help!!!!!!!!!!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int k,n;
int box[30][12];

int cmp1(const void *p,const void *q){
const int *a=p,*b=q;
int i,s1,s2;

for(i=0,s1=1,s2=1;i<n;i++)
{
s1 ...
by gladiatorcn
Fri Apr 01, 2005 9:31 am
Forum: Volume 1 (100-199)
Topic: 102 - Ecological Bin Packing
Replies: 485
Views: 116782

did u alphabetically list ur first answer? note that the order of input s bgc rather than bcg.
here s my codes, wishing to help:
#include <stdio.h>

int main()
{
long b[3][3];
int i,j,k;
long move,minmove;
char s[4];

while(scanf("%d%d%d%d%d%d%d%d%d",
&b[0][0],&b[0][2],&b[0][1],&b[1][0],&b[1 ...
by gladiatorcn
Fri Apr 01, 2005 9:13 am
Forum: Volume 1 (100-199)
Topic: 101 - The Blocks Problem
Replies: 635
Views: 108876

Thanx for ur sweet tips. I fixed all the problems, n still got TLE which bothers me a lot.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int stack[25][25];
int top[25],in_stack[25],index[25];
int n,i,j,p,q;

void popup(int x)
{
int k;
while(top[in_stack[x]]>index[x]+1)
{
k=stack[in ...
by gladiatorcn
Wed Mar 30, 2005 9:57 am
Forum: Volume 1 (100-199)
Topic: 101 - The Blocks Problem
Replies: 635
Views: 108876

101TE!!Help

My code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int stack[25][25];
int top[25],in_stack[25],index[25];
int n,i,j,p,q;

void popup(int x)
{
int k;
while(top[in_stack[x]]>index[x]+1)
{
k=stack[in_stack[x]][top[in_stack[x]]-1];
stack[k][top[k]++]=k;
in_stack[k]=k;
index[k ...

Go to advanced search