제출 #1056477

#제출 시각아이디문제언어결과실행 시간메모리
1056477mychecksedad죄수들의 도전 (IOI22_prison)C++17
80 / 100
8 ms1116 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(23, 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 <= 22; ++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); if(i == 22) x = 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; if(i == 22) -cur; } }else if(xx == 1){ if(x < 1){ ans[i][j] = -(3-cur); }else if(x > 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(i == 22) ans[i][j] = -(3-cur); } } if(ans[i][j] == 22){ ans[i][j] = -2; } if(ans[i][j] == 23){ ans[i][j] = 22; } if(ans[i][j] >= 24) 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; }

컴파일 시 표준 에러 (stderr) 메시지

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:66:23: warning: statement has no effect [-Wunused-value]
   66 |           if(i == 22) -cur;
      |                       ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...