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 ...
Search found 8 matches
- Sat Jan 14, 2006 6:54 pm
- Forum: Volume 1 (100-199)
- Topic: 112 - Tree Summing
- Replies: 137
- Views: 32363
- 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 ...
#include <iostream>
#include <math.h>
#include <map>
using namespace std;
int common_divisor(int a,int b ...
- 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 ...
#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 ...
- Sun Dec 11, 2005 3:10 pm
- Forum: Volume 1 (100-199)
- Topic: 102 - Ecological Bin Packing
- Replies: 485
- Views: 116782
- 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 ...
#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 ...
- Fri Apr 01, 2005 9:31 am
- Forum: Volume 1 (100-199)
- Topic: 102 - Ecological Bin Packing
- Replies: 485
- Views: 116782
- Fri Apr 01, 2005 9:13 am
- Forum: Volume 1 (100-199)
- Topic: 101 - The Blocks Problem
- Replies: 635
- Views: 108876
- 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 ...
#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 ...