제출 #1224443

#제출 시각아이디문제언어결과실행 시간메모리
1224443sokratisiInside information (BOI21_servers)C++20
10 / 100
51 ms1612 KiB
#include <bits/stdc++.h> using namespace std; int n, q, a, b; int toleft[125000], toright[125000]; char c; int main() { scanf("%d%d", &n, &q); for (int i = 0; i < n + q - 1; i++) { scanf("%c", &c); scanf("%c", &c); if (c == 'S') { scanf("%d%d", &a, &b); if (a > b) swap(a, b); // so a < b toright[a] = toright[b] + 1; toleft[b] = toleft[a] + 1; } if (c == 'Q') { scanf("%d%d", &a, &b); // does a store b if (a < b) { if (toright[a] >= b - a) { printf("yes\n"); } else { printf("no\n"); } } else { if (toleft[a] >= a - b) { printf("yes\n"); } else { printf("no\n"); } } } if (c == 'C') { scanf("%d", &a); int l = 1, r = a; int leftans; while (l <= r) { int m = (l + r) / 2; if (toright[m] >= a - m) { leftans = m; r = m - 1; } else { l = m + 1; } } l = a, r = n; int rightans; while (l <= r) { int m = (l + r) / 2; if (toleft[m] >= m - a) { rightans = m; l = m + 1; } else { r = m - 1; } } printf("%d\n", rightans - leftans + 1); } } 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:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%c", &c); scanf("%c", &c);
      |         ~~~~~^~~~~~~~~~
servers.cpp:12:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%c", &c); scanf("%c", &c);
      |                          ~~~~~^~~~~~~~~~
servers.cpp:14:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |             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 store b
      |             ~~~~~^~~~~~~~~~~~~~~~
servers.cpp:39:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |             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...