714C - Sonya and Queries - CodeForces Solution


data structures implementation *1400

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define endl "\n";
typedef long long int ll;
using namespace __gnu_pbds;
template <class type1>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll             long long
const long long        INF=1e18;
const int32_t          MM=998244353;
const int              N=1e7+5;
const int32_t          M=1e9+7;
ll __lcm(ll a,ll b){return (a*b)/__gcd(a,b);}
const ll MOD = 1e9 + 7;


int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);

      ll q;
      cin>>q;
      map<string,ll>m;
      while(q--){

        char c;
        cin>>c;

        ll num;
        cin>>num;

        string s=to_string(num);
        string temp="";
        for(int i=0;i<s.size();i++){
          int curr=s[i]-'0';
          curr%=2;
          char cc=(curr+'0');
          temp+=cc;
        }

          string temp2="";
          ll cnt=temp.size();
          while(cnt<18){
            temp2+='0';
            cnt++;
          }

          temp=temp2+temp;

          //cout<<temp<<endl;

          if(c=='+'){
            m[temp]++;
          }
          else if(c=='-'){
            m[temp]--;
          }
          else{
            cout<<m[temp]<<endl;
          }
      }
      




      return 0;

}


Comments

Submit
0 Comments
More Questions

1B - Spreadsheet
1177A - Digits Sequence (Easy Edition)
1579A - Casimir's String Solitaire
287B - Pipeline
510A - Fox And Snake
1520B - Ordinary Numbers
1624A - Plus One on the Subset
350A - TL
1487A - Arena
1520D - Same Differences
376A - Lever
1305A - Kuroni and the Gifts
1609A - Divide and Multiply
149B - Martian Clock
205A - Little Elephant and Rozdil
1609B - William the Vigilant
978B - File Name
1426B - Symmetric Matrix
732B - Cormen --- The Best Friend Of a Man
1369A - FashionabLee
1474B - Different Divisors
1632B - Roof Construction
388A - Fox and Box Accumulation
451A - Game With Sticks
768A - Oath of the Night's Watch
156C - Cipher
545D - Queue
459B - Pashmak and Flowers
1538A - Stone Game
1454C - Sequence Transformation