제출 #1224473

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

using namespace std;

int n, q, a, b;
char c;
int table[125000]; // what time did thing connecting 1 and b come

int main() {
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; i++) table[i] = INT_MAX;
    table[1] = -1;
    for (int i = 0; i < n + q - 1; i++) {
        scanf("%c", &c); scanf("%c", &c);
        if (c == 'S') {
            scanf("%d%d", &a, &b);
            table[max(a, b)] = i;
        }
        if (c == 'Q') {
            scanf("%d%d", &a, &b); // does a have b
            // iff d came before a
            if (b == 1) {
                if (table[a] != INT_MAX) printf("yes\n");
                else printf("no\n"); 
                continue;
            }
            if (a == 1) {
                if (table[b] != INT_MAX) printf("yes\n");
                else printf("no\n");
                continue;
            }
            if (table[b] <= table[a]) printf("yes\n");
            else printf("no\n");
        }
        if (c == 'C') {
            scanf("%d", &a);
            if (table[i] == INT_MAX) {
                printf("1\n");
            }
            else {
                printf("%d\n", table[a]+2);
            }
        }
    }

    return 0;
}

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