ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1795. Husband in a Shop

Show all messages Hide all messages

WA13 PLEASE, give me some test ANDREY TRUBIN 8 Mar 2011 14:59
#include <iostream>
using namespace std;
int main()
{long n,m,a[1010],b[1010],c[1010],k,i,e,j,q;
char t[1010][25],g[1010][25];
cin >> m;
for (i=1;i<=m;i++){
    cin >> a[i] >> t[0] >> t[i];
}
cin >> n;
for (i=1;i<=n;i++){
    cin >> b[i] >> g[0] >> g[i];
}
for (i=1;i<=n;i++)c[i]=0;

for (i=1;i<=n;i++){
    for (j=1;j<=m;j++){
        k=1;
        for (e=0;e<=21;e++){
            if (g[i][e]!=t[j][e])k=0;
        }
        if (k==1)c[i]=j;
    }
}
a[0]=0;
q=0;
for (i=1;i<=n;i++){
asd:;
    q++;
    if (a[c[i]]==0){goto lkj;}
    if (a[c[i]]>=b[i]){
        a[c[i]]=a[c[i]]-b[i];
        goto lkj;
    }
    if ((a[c[i]]<b[i])&&(i<n)){
        b[i]=b[i+1];
        b[i+1]=a[c[i]];
        k=c[i];
        c[i]=c[i+1];
        c[i+1]=k;
        goto asd;
    }
    if ((a[c[i]]<b[i])&&(i==n)){
        b[i]=a[c[i]];
        goto lkj;
    }
lkj:;
}
cout << q;
cin >> i;
    return 0;
}
check name "of"
Re: WA13 PLEASE, give me some test falicos 10 Mar 2012 19:28
you compare strings by the cycle
k=1;
        for (e=0;e<=21;e++){
            if (g[i][e]!=t[j][e])k=0;
        }
        if (k==1)c[i]=j;
this will be correct if you init arrays char t[1010][25],g[1010][25]; to 0.
And your program will take AC!!!