Submission #628154

#TimeUsernameProblemLanguageResultExecution timeMemory
628154jwvg0425Prisoner Challenge (IOI22_prison)C++17
0 / 100
0 ms212 KiB
#include <stdio.h> #include <vector> #include <queue> #include <algorithm> #include <iostream> #include <string> #include <bitset> #include <map> #include <set> #include <tuple> #include <string.h> #include <math.h> #include <random> #include <functional> #include <assert.h> #include <math.h> #define all(x) (x).begin(), (x).end() #define xx first #define yy second using namespace std; template<typename T, typename Pr = less<T>> using pq = priority_queue<T, vector<T>, Pr>; using i64 = long long int; using ii = pair<int, int>; using ii64 = pair<i64, i64>; vector<vector<int>> devise_strategy(int N) { const int BIT_SIZE = 13; vector<vector<int>> res(BIT_SIZE * 2, vector<int>(N + 1, 0)); res[0][0] = 0; for (int ai = 1; ai <= N; ai++) { int bit = 1 << BIT_SIZE; if ((ai & bit) == 0) res[0][ai] = 1; else res[0][ai] = 2; } for (int order = 1; order <= BIT_SIZE - 2; order++) { res[order * 2 - 1][0] = res[order * 2][0] = order % 2; int lbit = 1 << (BIT_SIZE - order + 1); int bit = 1 << (BIT_SIZE - order); int mine = order % 2 == 1 ? -2 : -1; int other = order % 2 == 1 ? -1 : -2; // order + 1번 비트가 같은지 보고 -> 다르면 order번 비트에 따라 다음 상태로 진행 for (int x = 1; x <= N; x++) { if ((x & lbit) == 0) { res[order * 2][x] = mine; res[order * 2 - 1][x] = x & bit ? order * 2 + 2 : order * 2 + 1; } else { res[order * 2 - 1][x] = other; res[order * 2][x] = x & bit ? order * 2 + 2 : order * 2 + 1; } } } { int order = BIT_SIZE - 1; res[order * 2 - 1][0] = order % 2; int lbit = 1 << (BIT_SIZE - order + 1); int bit = 1 << (BIT_SIZE - order); int mine = order % 2 == 1 ? -2 : -1; int other = order % 2 == 1 ? -1 : -2; for (int x = 1; x <= N; x++) { if ((x & lbit) == 0) { res[order * 2][x] = mine; res[order * 2 - 1][x] = order * 2 + 1; } else { res[order * 2 - 1][x] = other; res[order * 2][x] = order * 2 + 1; } } } { int order = BIT_SIZE; res[order * 2 - 1][0] = order % 2; int lbit = 1 << (BIT_SIZE - order + 1); int bit = 1 << (BIT_SIZE - order); int mine = order % 2 == 1 ? -2 : -1; int other = order % 2 == 1 ? -1 : -2; for (int x = 1; x <= N; x++) { if ((x & lbit) == 0) { res[order * 2 - 1][x] = mine; } else { res[order * 2 - 1][x] = (x & bit) ? other : mine; } } } return res; }

Compilation message (stderr)

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:73:7: warning: unused variable 'bit' [-Wunused-variable]
   73 |   int bit = 1 << (BIT_SIZE - order);
      |       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...