|
|
back to boardpeople, help!!!!!!!!!!!!! I always get WA#10 here is my solution #include <iostream> #include <vector> #include <string> #include <stack> using namespace std; int main(){ #ifndef ONLINE_JUDGE freopen("input.txt","rt",stdin); freopen("output.txt","wt",stdout); #endif string operation; stack <long > znach[1002]; short n; short int x; long y; cin >>n; for (short i=1; i<=n; i++){
cin >> operation;
if(operation=="PUSH"){ cin >> x; cin>>y; znach[x].push(y); }else{ cin >>x; long z=znach[x].top(); cout <<z<<endl; znach[x].pop(); }
} } one who finds a mistake, please write back Re: people, help!!!!!!!!!!!!! are you crazy, man? It's not too easy problem as you think.You should write your OWN stack Re: people, help!!!!!!!!!!!!! are you crazy, man? It's not too easy problem as you think.You should write your OWN stack @Jew on the space Hey, please be more respectful. He complains about receiving WA not MLE so he has a point. @alex kichkin The problem in your code is that you declared i and n as shorts (which is 2 bytes) but n can be at most 100000 (so 4 bytes is needed). Changing your code with int type for i and n gives correct MLE now. Further on, as Jew on the space suggested, you should develop yourself a stack, more suitable with the problem constraints. Cheers |
|
|