Submission #1055873

#TimeUsernameProblemLanguageResultExecution timeMemory
1055873vjudge1Prisoner Challenge (IOI22_prison)C++17
100 / 100
7 ms1372 KiB
#include "prison.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; using ii = pair<int, int>; vector<vi> expand(vector<vi> S, int a, int nr, int tip) { for(auto &lin : S) { lin[0] ^= 1; for(int i = 1; i < int(lin.size()); ++i) { if(lin[i] < 0) lin[i] = -3 - lin[i]; else lin[i] += nr; } } int lenS = int(S.size()); vector<vi> Re(int(S.size()) + nr, vi(nr * a + 3, -1)); for(int i = 1; i < lenS; ++i) { //Re[i + nr] Re[i + nr][0] = S[i][0]; for(int d = 0; d < nr; ++d) { for(int j = 1; j <= a; ++j) { Re[i + nr][d * a + j + 1] = S[i][j]; /// se repeta } } } for(int i = 1; i <= nr; ++i) { ///Re[i] -> 2 + (i - 1) * a ... 1 + i * a Re[i][0] = 1; for(int j = 1; j < (i - 1) * a + 2; ++j) { Re[i][j] = -2; } for(int j = (i - 1) * a + 2; j <= 1 + i * a; ++j) { Re[i][j] = S[0][(j - 2) % a + 1]; } for(int j = 1 + i * a + 1; j < Re[i].size(); ++j) { Re[i][j] = -1; } } Re[0][0] = 0; Re[0][1] = -1; Re[0].back() = -2; for(int d = 1; d <= nr; ++d) { for(int i = (d - 1) * a + 2; i <= d * a + 1; ++i) { Re[0][i] = d; } } return Re; } vector<vi> devise_strategy(int n) { vi Ord = {2, 3, 3, 3, 3, 3, 3}; vector<vi> S = {vi{0, -1, -2}}; int a = 2; int tip = 1; for(auto it : Ord) { S = expand(S, a, it, tip); tip ^= 1; a = it * a + 2; // cout << S[0].size() << " " << a << "\n"; } // cerr << S.size() << " " << S[1].size() << "\n"; for(int i = 0; i < S.size(); ++i) S[i].resize(n + 1); return S; }

Compilation message (stderr)

prison.cpp: In function 'std::vector<std::vector<int> > expand(std::vector<std::vector<int> >, int, int, int)':
prison.cpp:42:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for(int j = 1 + i * a + 1; j < Re[i].size(); ++j) {
      |                                    ~~^~~~~~~~~~~~~~
prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:69:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     for(int i = 0; i < S.size(); ++i)
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...