Skip to content

Instantly share code, notes, and snippets.

@ravikiran0606
Last active July 28, 2016 12:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravikiran0606/bba186e03cf4c5013d58c9d4efb3d4e2 to your computer and use it in GitHub Desktop.
Save ravikiran0606/bba186e03cf4c5013d58c9d4efb3d4e2 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
int main()
{
long int n,q,x,i,ans;
char ch;
cin>>n>>q;
int a[n]={0};
next:
while(q--)
{
cin>>ch;
cin>>x;
if(ch=='C')
{
if(a[x]==0)
a[x]=1;
else
a[x]=0;
}
else
{
for(i=x;i<n;i++)
{
if(a[i]==1)
{
cout<<i<<endl;
goto next;
}
}
cout<<"-1"<<endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment