제출 #849036

#제출 시각아이디문제언어결과실행 시간메모리
849036grossly_overconfident죄수들의 도전 (IOI22_prison)C++17
0 / 100
1 ms344 KiB
#include <bits/stdc++.h> using namespace std; int solve(int a){ if (a == 1){ return 1; } if (a == 10){ return 2; } if (a == 100){ return 3; } if (a == 1000){ return 4; } return ceil(log10(a)); } int find_digit(int a, int i){ return (to_string(a)[i] - 48); } vector<vector<int>> devise_strategy(int n){ int x = 100; vector<vector<int>> out(x, vector<int>(n + 1)); for (int i = 1; i <= n; ++i){ out[0][i] = solve(i); } for (int i = 1; i <= 4; ++i){ out[i][0] = 1; for (int j = 1; j <= n; ++j){ if (solve(j) > i){ out[i][j] = -1; continue; } if (solve(j) < i){ out[i][j] = -2; continue; } out[i][j] = 10 + find_digit(j, 0); } } for (int i = 10; i <= 19; ++i){ out[i][0] = 0; for (int j = 1; j <= n; ++j){ int k = find_digit(j, 0); if (k > i - 10){ out[i][j] = -2; continue; } if (k < i - 10){ out[i][j] = -1; continue; } out[i][j] = 20 + find_digit(j, 1); } } for (int i = 20; i <= 29; ++i){ out[i][0] = 1; for (int j = 1; j <= n; ++j){ int k = find_digit(j, 1); if (k > i - 20){ out[i][j] = -1; continue; } if (k < i - 20){ out[i][j] = -2; continue; } out[i][j] = 30 + find_digit(j, 2); } } for (int i = 30; i <= 39; ++i){ out[i][0] = 0; for (int j = 1; j <= n; ++j){ int k = find_digit(j, 2); if (k > i - 30){ out[i][j] = -2; continue; } if (k < i - 30){ out[i][j] = -1; continue; } out[i][j] = 40 + find_digit(j, 3); } } for (int i = 40; i <= 49; ++i){ out[i][0] = 1; for (int j = 1; j <= n; ++j){ int k = find_digit(j, 3); if (k > i - 40){ out[i][j] = -1; continue; } if (k < i - 40){ out[i][j] = -2; } } } return out; } signed maint(){ int a, b; cin >> a >> b; int n = 5000; vector<vector<int>> strats = devise_strategy(n); int whiteboard = 0; while (whiteboard >= 0){ if (strats[whiteboard][0] == 0){ whiteboard = strats[whiteboard][a]; } else{ whiteboard = strats[whiteboard][b]; } } cout << whiteboard; }

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

prison.cpp: In function 'int maint()':
prison.cpp:125:1: warning: no return statement in function returning non-void [-Wreturn-type]
  125 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...