1 solutions

  • 0
    @ 2024-12-4 19:37:03

    C :

    #include<stdio.h>
    int main()
    {
        int n,t,p,q[100000],s;
        char a[50];
        while(scanf("%d%d",&n,&t)!=EOF)
        {
            getchar();
            for(p=0;p<n;p++)
            {
                q[p]=0;
            }
            while(t--)
            {
                scanf("%s",&a);
                if(a[0]=='C')
                {
                    scanf("%d",&p);
                    if(q[p-1])q[p-1]=0;
                    else q[p-1]=1;
                }
                else
                {
                    s=0;
                    for(p=0;p<n;p++)
                    {
                        s+=q[p];
                    }
                    printf("%d\n",s);
                }
            }
        }
        return 0;
    }
    
    

    C++ :

     
    #include<stdio.h>
    bool a[100010];
    int main()
    {
    	int n,m,t,k,l,count=0;
    	char c[10];
    	scanf("%d%d",&n,&t);
    	while(t--)
    	{
    		scanf("%s",c);
    		if(c[0]=='C')
    		{
    			scanf("%d",&l);
    			a[l]=!a[l];
    			if(a[l]==1)
    			count++;
    			else
    				count--;
    		}
    		if(c[0]=='Q')
    			printf("%d\n",count);
    	}
    return 0;
    }
            
    
    • 1

    Information

    ID
    2242
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    (None)
    # Submissions
    0
    Accepted
    0
    Uploaded By