Submission #1224547

#TimeUsernameProblemLanguageResultExecution timeMemory
1224547sokratisiInside information (BOI21_servers)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int n, q, a, b; char c; int child[2][125000]; vector<int> brep[2]; void brep(int i, int a) { while (a) { brep[i].push_back(a%2); a/2; } reverse(brep[i].begin(), brep[i].end()); } int main() { scanf("%d%d", &n, &q); int cnt = 0; 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); if (b % 2 == 1) child[1][a] = cnt++; else child[0][a] = cnt++; } else if (c == 'Q') { scanf("%d%d", &a, &b); // has b traveled to a?? // route from b to a has to be increasing brep[0].clear(); brep[1].clear(); brep(0, a); brep(1, b); int ind = -1; int cur = 1; for (int i = 0; i < min(brep[0].size(), brep[1].size()); i++) { if (brep[0][i] == brep[1][i]) { cur *= 2; cur += brep[0][i]; ind = i; } else break; } int lst = -1; bool okay = true; int curcop = cur; // first loop is from lca to a, has to be inceasing for (int i = ind+1; i < brep[0].size(); i++) { if (child[brep[0][i]][curcop]<lst) okay = false; lst = child[brep[0][i]][curcop]; curcop *= 2; curcop += brep[0][i]; } lst = INT_MAX; curcop = cur; for (int i = ind+1; i < breop[1].size(); i++) { if (child[brep[1][i]][curcop] > lst) okay = false; lst = child[brep[1][i]][curcop]; curcop *= 2; curcop += brep[1][i]; } if (okay) printf("yes\n"); else printf("no\n"); } } return 0; }

Compilation message (stderr)

servers.cpp:10:23: error: 'void brep(int, int)' redeclared as different kind of entity
   10 | void brep(int i, int a) {
      |                       ^
servers.cpp:8:13: note: previous declaration 'std::vector<int> brep [2]'
    8 | vector<int> brep[2];
      |             ^~~~
servers.cpp: In function 'int main()':
servers.cpp:33:17: error: 'brep' cannot be used as a function
   33 |             brep(0, a); brep(1, b);
      |             ~~~~^~~~~~
servers.cpp:33:29: error: 'brep' cannot be used as a function
   33 |             brep(0, a); brep(1, b);
      |                         ~~~~^~~~~~
servers.cpp:56:37: error: 'breop' was not declared in this scope; did you mean 'brep'?
   56 |             for (int i = ind+1; i < breop[1].size(); i++) {
      |                                     ^~~~~
      |                                     brep
servers.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d%d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~
servers.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%c", &c); scanf("%c", &c);
      |         ~~~~~^~~~~~~~~~
servers.cpp:22:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%c", &c); scanf("%c", &c);
      |                          ~~~~~^~~~~~~~~~
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:30:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |             scanf("%d%d", &a, &b); // has b traveled to a??
      |             ~~~~~^~~~~~~~~~~~~~~~