제출 #1224452

#제출 시각아이디문제언어결과실행 시간메모리
1224452sokratisiInside information (BOI21_servers)C++20
5 / 100
1602 ms16576 KiB
#include <bits/stdc++.h>

using namespace std;

int n, q, a, b;
char c;
bool table[4005][4005]; // table[i][j] does i have j


int main() {
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; i++) table[i][i] = true;
    for (int i = 0; i < n + q - 1; i++) {
        scanf("%c", &c); scanf("%c", &c); 
        if (c == 'S') {
            scanf("%d%d", &a, &b);
            for (int j = 1; j <= n; j++) {
                if (table[a][j] == true) table[b][j] = true;
                if (table[b][j] == true) table[a][j] = true;
            }
        }
        if (c == 'Q') {
            scanf("%d%d", &a, &b); // does a have d
            if (table[a][b]) printf("yes\n");
            else printf("no\n");
        }
        if (c == 'C') {
            scanf("%d", &a);
            int cnt = 0;
            for (int i = 1; i <= n; i++) if (table[i][a]) cnt++;
            printf("%d\n", cnt);
        }
    }

    return 0;
}

컴파일 시 표준 에러 (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:23:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |             scanf("%d%d", &a, &b); // does a have d
      |             ~~~~~^~~~~~~~~~~~~~~~
servers.cpp:28:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |             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...