Need help in debugging code of Codeforces round 662Div 2 problem B
Difference between en1 and en2, changed 1,194 character(s)
I am not able to find any bug in my code of today's contest 662Div2 problem B.Here is my submission:- ↵
 https://codeforces.net/contest/1393/submission/89277043.
Here is my code also:-↵

Code:-↵
#include<bits/stdc++.h>↵
using namespace std;↵
#define light ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);↵
int m=2e5;↵
int main()↵
{↵
    light;↵
    int n,q,i,sum=0;↵
    cin>>n;↵
    vector<int>b(m+1,0),c(m+1,0);↵
    for(i=0;i<n;i++)↵
    {↵
        int a;cin>>a;↵
        b[a]++;↵
    }↵
    for(i=1;i<=m;i++)↵
    {↵
        if(b[i])↵
            c[b[i]]++;↵
    }↵
    for(i=8;i<=m;i++)↵
        sum+=c[i];↵
    cin>>q;↵
    while(q--)↵
    {↵
        char ch;int x;↵
        cin>>ch>>x;↵
        if(ch=='+')↵
        {↵
            if(b[x])↵
                c[b[x]]--;↵
            b[x]++;c[b[x]]++;↵
            if(b[x]==8)↵
                sum++;↵
        }↵
        else↵
        {↵
            c[b[x]]--;b[x]--;↵
            if(b[x])↵
                c[b[x]]++;↵
            if(b[x]==7)↵
                sum--;↵
        }↵
        if(sum)↵
            cout<<"YES\n";↵
        else if(c[6]&&(c[2]||c[3]||c[4]||c[5]||c[7]))↵
            cout<<"YES\n";↵
        else if(c[7]&&(c[2]||c[3]||c[4]||c[5]||c[6]))↵
            cout<<"YES\n";↵
        else if(c[4]>1||c[5]>1||c[6]>1||c[7]>1)↵
            cout<<"YES\n";↵
        else↵
            cout<<"NO\n";↵
    }↵
}
Any kind of help is much appreciated.↵

Thank you.


History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Dontony 2020-08-07 20:15:28 1194
en1 English Dontony 2020-08-07 20:14:10 1444 Initial revision (published)