제출 #1224453

#제출 시각아이디문제언어결과실행 시간메모리
1224453KALARRYInside information (BOI21_servers)C++20
2 / 100
3609 ms589824 KiB
//chockolateman

#include<bits/stdc++.h>

using namespace std;

int N,K,counter[120005],x[120005],y[120005];
char op[120005];
set<int> contain[120005];

int main()
{
    scanf("%d%d",&N,&K);
    for(int i = 1 ; i <= N ; i++)
    {
        counter[i] = 1;
        contain[i].insert(i);
    }
    // for(int i = 1 ; i <= N + K - 1 ; i++) 
    // {
    //     scanf(" %c",&op[i]);
    //     scanf("%d",&x[i]);
    //     if(op[i] != 'C')
    //         scanf("%d",&y[i]);
    // }
    for(int a,b,i = 1 ; i <= N + K - 1 ; i++)
    {
        scanf(" %c",&op[i]);
        scanf("%d",&x[i]);
        if(op[i] != 'C')
            scanf("%d",&y[i]);
        a = x[i];
        b = y[i];
        if(op[i]=='C')
            printf("%d\n",counter[a]);
        else if(op[i]=='Q')
        {
            scanf("%d",&b);
            if(contain[a].count(b))
                printf("yes\n");
            else
                printf("no\n");
        }
        else
        {
            scanf("%d",&b);
            for(auto l : contain[a])
            {
                if(contain[b].count(l)==0)
                    counter[l]++;
                contain[b].insert(l);
            }
            for(auto l : contain[b])
            {
                if(contain[a].count(l)==0)
                    counter[l]++;
                contain[a].insert(l);
            }
        }

    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

servers.cpp: In function 'int main()':
servers.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d%d",&N,&K);
      |     ~~~~~^~~~~~~~~~~~~~
servers.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf(" %c",&op[i]);
      |         ~~~~~^~~~~~~~~~~~~~
servers.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%d",&x[i]);
      |         ~~~~~^~~~~~~~~~~~
servers.cpp:31:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |             scanf("%d",&y[i]);
      |             ~~~~~^~~~~~~~~~~~
servers.cpp:38:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |             scanf("%d",&b);
      |             ~~~~~^~~~~~~~~
servers.cpp:46:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |             scanf("%d",&b);
      |             ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...