Submission #1101127

#TimeUsernameProblemLanguageResultExecution timeMemory
1101127rainboyMachine (IOI24_machine)C++17
100 / 100
9 ms592 KiB
#include "machine.h" #include <vector> using namespace std; typedef vector<int> vi; const int L = 8; vi find_permutation(int n) { vi aa(n); for (int i = 0; i < n; i++) aa[i] = i; if (n % 2 == 0) { int l = 0; while (1 << l + 1 <= n) l++; aa[(1 << l) - 1] = (n + 2 & n + 1) == 0 ? n + 2 : n; } vi pp = use_machine(aa); int x = 0; for (int l = 0; l < L; l++) { int d = 0; for (int i = 0; i < n; i++) d += (pp[i] & 1 << l) != 0 ? 1 : -1; if (d > 0) x ^= 1 << l; } for (int i = 0; i < n; i++) pp[i] ^= x; if (n % 2 == 0) { int l = 0; while (1 << l + 1 <= n) l++; for (int i = 0; i < n; i++) if (pp[i] >= n) { pp[i] = (1 << l) - 1; break; } } return pp; }

Compilation message (stderr)

machine.cpp: In function 'vi find_permutation(int)':
machine.cpp:16:17: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   16 |   while (1 << l + 1 <= n)
      |               ~~^~~
machine.cpp:18:25: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
   18 |   aa[(1 << l) - 1] = (n + 2 & n + 1) == 0 ? n + 2 : n;
      |                       ~~^~~
machine.cpp:33:17: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   33 |   while (1 << l + 1 <= n)
      |               ~~^~~
#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...