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 1992. CVS

WA4
Posted by Ctalk3r 1 Aug 2017 15:23
#include <iostream>
#include <vector>
using namespace std;

string per(int x)
{
int k(0),b(x);
string m;
if (x<10) {m+=char(x+'0');return m;}
while(x!=0)
{
 x=x/10;
 k++;
}
x=b;
b=k;
string s;
while(k>0)
{
 s+=char((x%10)+'0');
 x=(x-x%10)/10;
 k--;
}
for(int i=0;i<b;i++)
 m+=s[b-i-1];
return m;
}

int main()
{
int n,m,i,j,p,t(1);
char s[80];
string Y;
vector<int> v;
vector<int> w;
v.reserve(1);
w.reserve(1);
scanf("%d",&n);
scanf("%d",&m);

for(int d=0;d<n;d++)
{
 scanf("%s",s);
 if(s[0]=='l')
  {
  scanf("%d%d",&i,&j);
  if(j>m) continue;
  if(t<i) continue;
  v.push_back(j);w.push_back(i);
  p=w.size();
  for(int x=0;x<p;x++)
   if(w[x]==i && v[x]<0) {v.erase(v.begin()+x);w.erase(w.begin()+x);}
   }
 if(s[0]=='r'&& s[1]=='o')
  {
  scanf("%d",&i);
  p=w.size()-1;
  while(v[p]<0 || w[p]!=i)
   p--;
  v[p]-=1000000;}
 if(s[0]=='c'&& s[1]=='h')
{
 scanf("%d",&i);
 if(w.size()>0)
{
  for(int x=w.size()-1;x>=0;x--)
   if(w[x]==i && v[x]>0) {Y+=per(v[x]);if(d!=n-1)Y+="\n";break;}
   else
    if (x==0) {Y+="basic";if(d!=n-1)Y+="\n";}
    }
 else {Y+="basic";if(d!=n-1) Y+="\n";}

}
 if(s[0]=='r'&& s[1]=='e')
 {
  scanf("%d",&i);
  p=0;
  while(v[p]>0 || w[p]!=i)
   {
   p++;
   if(p>w.size()-1)
    break;
   }
  if(p>=0) v[p]+=1000000;
 }
 if(s[0]=='c'&& s[1]=='l')
{
 if(t<i) continue;
 t++;
 scanf("%d",&i);
 p=w.size();
 for(int x=0;x<p;x++)
  if(w[x]==i) {v.push_back(v[x]);w.push_back(t);}
}
}

cout<<Y;
}


I can't make up any new tests. Everything, I tried, works. If you have some ideas, please, help



Edited by author 01.08.2017 15:26

Edited by author 01.08.2017 15:28
Re: WA4
Posted by Ctalk3r 2 Aug 2017 00:31
The problem is connected with recoil