[ create a new paste ] login | about

Link: http://codepad.org/zrZTXOBM    [ raw code | output | fork ]

C++, pasted on Sep 14:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mem(n) memset(n,0,sizeof(n))
#define tst int tst; scanf("%d",&tst) ; while(tst--)
#define LCM(a,b) (a / __gcd(a,b) ) * b
#define gcd(a,b) __gcd(a,b)
#define Case printf("Case %d: ",cs++);
#define for0(l,n) for(int l=0;l<n;l++)
#define for1(l,n) for(int l=1;l<=n;l++)
#define pool(n) for(int i=n-1;i>=0;i--)
#define bug(n) cout<<">> "<<n<<" <<";
#define szv(v) v.size()
#define sz(a) sizeof(a)
#define YES printf("YES\n")
#define NO printf("NO\n")
#define Yes printf("Yes\n")
#define No printf("No\n")
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define cl(v) v.clear;
#define maxall(v) *max_element(v.begin(),v.end())
#define minall(v) *min_element(v.begin(),v.end())
#define P1(a) cout<<a<<endl;
#define P2(a,b) cout<<a<<" "<<b<<endl;
#define P3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl;
#define S1(a) cin>>a;
#define S2(a,b)cin>>a>>b;

map<string,int> cnt;
map<string,string> mp;


string makeitbinary(string arr)
{
    int len = arr.size();
    char temp[18];
    int p=len-1;
   for(int i=17;i>(17-len);i--)
   {
        if((arr[p--]-'0')%2==0)temp[i]='0';
        else temp[i]='1';
   }
   for(int i=0;i<=17-len;i++)
    {
        temp[i]='0';
    }
    return temp;
}

int main()
{
    string temp,arr,bin;
    int n;
   cin>>n;

    mp.clear();
    cnt.clear();
    for0(i,n)
    {
        char ch;
        cin>>ch>>arr;
        if(ch=='+')
        {
           temp= makeitbinary(arr);

           cnt[temp]++;
           mp[arr]=temp;
         //  bug(temp);
        }
        else if(ch=='-')
        {
            cnt[mp[arr]]--;
        }
        else if(ch=='?')
        {
            bin= makeitbinary(arr);
            cout<<cnt[bin]<<endl;
        }
    }
}


Output:
1
Line 23: error: bits/stdc++.h: No such file or directory


Create a new paste based on this one


Comments: