Submission #1224640

#TimeUsernameProblemLanguageResultExecution timeMemory
1224640sokratisiInside information (BOI21_servers)C++20
2 / 100
2150 ms589824 KiB
#include <bits/stdc++.h>

using namespace std;

int n, q, a, b;
char c;
set<int> table[125000]; // table[{i, j}] does i have j
int cq[125000];

int main() {
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; i++) table[i].insert(i);
    for (int i = 0; i < n + q - 1; i++) {
        scanf("%c", &c); scanf("%c", &c); 
        if (c == 'S') {
            scanf("%d%d", &a, &b);
            for (auto u: table[a]) {
                table[b].insert(u);
                cq[u]++;
            }
            for (auto u: table[b]) {
                table[a].insert(u);
                cq[u]++;
            }
        }
        if (c == 'Q') {
            scanf("%d%d", &a, &b); // does a have d
            if (table[a].find(b) != table[a].end()) printf("yes\n");
            else printf("no\n");
        }
        if (c == 'C') {
            scanf("%d", &a);
            printf("%d\n", cq[a] + 1);
        }
    }

    return 0;
}

Compilation message (stderr)

servers.cpp: In function 'int main()':
servers.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d%d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~
servers.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%c", &c); scanf("%c", &c);
      |         ~~~~~^~~~~~~~~~
servers.cpp:14:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%c", &c); scanf("%c", &c);
      |                          ~~~~~^~~~~~~~~~
servers.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |             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, &b); // does a have d
      |             ~~~~~^~~~~~~~~~~~~~~~
servers.cpp:32:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |             scanf("%d", &a);
      |             ~~~~~^~~~~~~~~~
#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...