Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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
You can’t perform that action at this time.