Submission #1224323

#TimeUsernameProblemLanguageResultExecution timeMemory
1224323lkaterisInside information (BOI21_servers)C++20
5 / 100
1695 ms16576 KiB
#include <iostream>

using namespace std;

bool M[4005][4005];

int main() {

    int N,K;
    scanf("%d%d",&N,&K);

    for(int i=1;i<=N;++i) M[i][i] = true;

    for(int q=1;q<=N+K-1;++q) {
        char t;
        scanf("\n%c",&t);
        if (t == 'S') {
            int a,b;
            scanf("%d%d",&a,&b);
            for(int i=1;i<=N;++i) {
                if (M[a][i] == true) M[b][i] = true;
                if (M[b][i] == true) M[a][i] = true;
            }
        }
        else if (t == 'Q') {
            int a,d;
            scanf("%d%d",&a,&d);
            if (M[a][d]) printf("yes\n");
            else printf("no\n");

        }
        else if (t == 'C') {
            int d;
            scanf("%d",&d);
            int res=0;
            for(int i=1;i<=N;++i) {
                if (M[i][d]) res++;
            }
            printf("%d\n",res);
        }

    }


    return 0;
}

Compilation message (stderr)

servers.cpp: In function 'int main()':
servers.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d%d",&N,&K);
      |     ~~~~~^~~~~~~~~~~~~~
servers.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("\n%c",&t);
      |         ~~~~~^~~~~~~~~~~
servers.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |             scanf("%d%d",&a,&b);
      |             ~~~~~^~~~~~~~~~~~~~
servers.cpp:27:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |             scanf("%d%d",&a,&d);
      |             ~~~~~^~~~~~~~~~~~~~
servers.cpp:34:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |             scanf("%d",&d);
      |             ~~~~~^~~~~~~~~
#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...