제출 #1023425

#제출 시각아이디문제언어결과실행 시간메모리
1023425Issa죄수들의 도전 (IOI22_prison)C++17
100 / 100
8 ms1116 KiB
#include <bits/stdc++.h> using namespace std; vector<pair<int, int>> g[10]; int a[10]; int f[10]; int get(int j, int x, int i = 8){ if(i == j) return x; for(auto [l, r]: g[i]){ if(x >= l && x <= r){ return get(j, x - l + 1, i - 1); } } return -1; } std::vector<std::vector<int>> devise_strategy(int N){ vector<vector<int>> s(21, vector<int>(N + 1, 0)); a[8] = 5588; for(int i = 8; i > 3; i--){ int k = (a[i] - 2) / 3; g[i].push_back({2, k + 1}); g[i].push_back({k + 2, k * 2 + 1}); g[i].push_back({k * 2 + 2, a[i] - 1}); a[i-1] = k; } for(int i = 3; i > 1; i--){ int k = (a[i] - 2) / 2; g[i].push_back({2, k + 1}); g[i].push_back({k + 2, a[i] - 1}); a[i-1] = k; } g[1] = {{2, 3}}; for(int i = 2; i <= 8; i++){ f[i] = f[i-1] + g[i-1].size(); } for(int i = 1; i <= 8; i++){ for(int c = 0; c < g[i].size(); c++){ int x = f[i] + c + 1; s[x][0] = i & 1; for(int j = 1; j <= N; j++){ int w = get(i, j); if(w < 0) continue; if(w == 1) s[x][j] = - s[x][0] - 1; else if(w == a[i]) s[x][j] = - (s[x][0] ^ 1) - 1; else{ int c1 = 0; while(g[i][c1].second < w) c1++; if(c1 < c) s[x][j] = - s[x][0] - 1; else if(c1 > c) s[x][j] = - (s[x][0] ^ 1) - 1; else if(g[i][c1].first == w) s[x][j] = - s[x][0] - 1; else if(g[i][c1].second == w) s[x][j] = - (s[x][0] ^ 1) - 1; else{ w = get(i - 1, j); c1 = 0; while(g[i-1][c1].second < w) c1++; s[x][j] = f[i-1] + c1 + 1; } } } } } s[0][0] = 1; for(int i = 1; i <= N; i++){ if(i == 1) s[0][i] = -2; else{ int c = 0; while(g[8][c].second < i) c++; s[0][i] = f[8] + c + 1; } } return s; }

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

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:41:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   for(int c = 0; c < g[i].size(); c++){
      |                  ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...