Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<map>
- using namespace std;
- map<int,bool> mMap;
- int main()
- {
- int n,a,b;
- bool k;
- cin>>n;
- for(int i=0;i<n;i++)
- mMap[i]=0;//mMap[i]=0 indicates it as tail.. else 1 for head;
- cin>>n;
- for(int i=0;i<n;i++)
- {
- cin>>k>>a>>b;
- if(k)//k==1 counting heads
- {
- int count = 0;
- for(int j=a;j<=b;j++)
- if(mMap[j])count++;//when mMap[j]=1 count of head increments..
- cout<<count<<endl;
- }
- else
- {
- for(int j=a;j<=b;j++)//from mMap[a]to mMap[b] fliping the coins..
- mMap[j]=!(mMap[j]);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement