Submission #408720

#TimeUsernameProblemLanguageResultExecution timeMemory
408720ly20Inside information (BOI21_servers)C++17
5 / 100
90 ms3924 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 121234; int v[MAXN]; int main() { int n, k; scanf("%d %d", &n, &k); k += n - 1; for(int i = 1; i <= n; i++) v[i] = -1; int id = 0; v[1] = 0; id++; for(int i = 0; i < k; i++) { char c; scanf(" %c", &c); if(c == 'S') { int a, b; scanf("%d %d", &a, &b); if(a != 1) swap(a, b); v[b] = id++; } else if(c == 'Q') { int a, b; scanf("%d %d", &a, &b); if(a == b) printf("yes\n"); else if(v[b] == -1 || v[a] == -1 ) printf("no\n"); else if(v[a] > v[b] || (a == 1 && v[b] != 0)) printf("yes\n"); else printf("no\n"); } else { int a; scanf("%d", &a); if(v[a] == -1) printf("1\n"); else if(a != 1) printf("%d\n", id - v[a] + 1); else printf("%d\n", id - v[a]); } } }

Compilation message (stderr)

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