Last active
July 28, 2016 12:25
-
-
Save ravikiran0606/bba186e03cf4c5013d58c9d4efb3d4e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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