Submission #1056431

#TimeUsernameProblemLanguageResultExecution timeMemory
1056431mychecksedadPrisoner Challenge (IOI22_prison)C++17
0 / 100
5 ms996 KiB
#include "prison.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define all(x) x.begin(),x.end() #define ll long long int #define en cout << '\n' #define pi pair<int,int> #define vi vector<int> #define ff first #define ss second int t[8]={ 1, 3, 9, 27, 81, 243, 729, 2187 }; int get(int num, int div){ if(div == -1) return 0; for(int i = 7; i > div; --i){ while(num >= t[i]) num -= t[i]; } return num / t[div]; } std::vector<std::vector<int>> devise_strategy(int n) { vector<vector<int>> ans(25, vector<int>(n+1, 0)); // cout << get(2, 1) << ' '; ans[0][0] = 0; for(int i = 1; i <= n; ++i){ ans[0][i] = get(i, 7) + 1; } int tot = 8; for(int i = 1; i <= 24; ++i){ int bit = tot-(i+2)/3; // cout << bit << ' '; int cur; if(bit % 2 == 0){ ans[i][0] = 0; cur = 1; }else{ ans[i][0] = 1; cur = 2; } // int nx = (1<<(bit-1)); int ii = (i%3==0 ? i + 1 : (i % 3 == 1 ? i + 3 : i + 2)); int x = i%3 == 0 ? 2 : (i % 3 == 1 ? 0 : 1); // cout << i << ' ' << ii << '\n'; for(int j = 1; j <= n; ++j){ int xx = get(j, bit); if(xx == 0){ if(x > 0){ ans[i][j] = -cur; }else{ int nxt = get(j, bit - 1); ans[i][j] = ii + nxt; } }else if(xx == 1){ if(x < 1){ ans[i][j] = -(3-cur); }else if(i % 3 > 1){ ans[i][j] = -cur; }else{ int nxt = get(j, bit - 1); ans[i][j] = ii + nxt; } }else{ if(x < 2){ ans[i][j] = -(3-cur); }else{ int nxt = get(j, bit - 1); ans[i][j] = ii + nxt; } } if(ans[i][j] >= 25) ans[i][j] = -1; } } // for(int i = 0; i <= 24; ++i){ // for(int j = 0; j <= n; ++j) cout << ans[i][j] << ' '; // en; // } // for(auto &v: ans){ // for(auto &u: v){ // if(u == 26) u = 1; // } // } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...