제출 #824248

#제출 시각아이디문제언어결과실행 시간메모리
824248esomer죄수들의 도전 (IOI22_prison)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<vector<int>> ans(23); vector<vector<int>> inds(8); int val(int n, int exp){ vector<ll> pw(9); pw[0] = 1; for(int i = 1; i <= 8; i++) pw[i] = pw[i-1] * 3; for(int i = 8; i >= 0; i--){ int which; if(n >= pw[i] * 2) {n -= pw[i] * 2; which = 2;} else if(n >= pw[i]) {n -= pw[i]; which = 1;} else{ which = 0; } if(i == exp) return which; } return 0; } void build(int ind, int exp, int should){ if(exp == 0){ for(int i = 1; i <= N; i++){ int which = val(i, exp); if(which != should){ if(which > should) ans[ind][i] = -(ans[ind][0] + 1); else ans[ind][i] = -((1 - ans[ind][0]) + 1); } } return; } if(exp == 1){ //Optimize 2 queries. for(int i : inds[exp - 1]){ ans[i][0] = 1 - ans[ind][0]; } for(int i = 1; i <= N; i++){ int which = val(i, exp); if(which != should){ if(which > should) ans[ind][i] = -(ans[ind][0] + 1); else ans[ind][i] = -((1 - ans[ind][0]) + 1); }else{ which = val(i, exp - 1); if(which == 2){ ans[ind][i] = -(ans[ind][0] + 1); }else if(which == 0){ ans[ind][i] = -((1 - ans[ind][0]) + 1); }else{ ans[ind][i] = inds[exp-1][0]; } } } build(inds[exp - 1][0], exp - 1, 1); return; } for(int i : inds[exp - 1]){ ans[i][0] = 1 - ans[ind][0]; } for(int i = 1; i <= N; i++){ int which = val(i, exp); if(which != should){ if(which > should) ans[ind][i] = -(ans[ind][0] + 1); else ans[ind][i] = -((1 - ans[ind][0]) + 1); }else{ which = val(i, exp - 1); ans[ind][i] = inds[exp-1][which]; } } build(inds[exp - 1][0], exp - 1, 0); build(inds[exp - 1][1], exp - 1, 1); build(inds[exp - 1][2], exp - 1, 2); } vector<vector<int>> devise_strategy(int N) { ans[0][0] = 0; int curr = 1; for(int i = 7; i >= 1; i--){ inds[i].push_back(curr); curr++; inds[i].push_back(curr); curr++; inds[i].push_back(curr); curr++; } inds[0].push_back(curr); build(0, 8, 0); return ans; }

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

prison.cpp: In function 'int val(int, int)':
prison.cpp:9:9: error: 'll' was not declared in this scope
    9 |  vector<ll> pw(9);
      |         ^~
prison.cpp:9:11: error: template argument 1 is invalid
    9 |  vector<ll> pw(9);
      |           ^
prison.cpp:9:11: error: template argument 2 is invalid
prison.cpp:10:4: error: invalid types 'int[int]' for array subscript
   10 |  pw[0] = 1;
      |    ^
prison.cpp:11:32: error: invalid types 'int[int]' for array subscript
   11 |  for(int i = 1; i <= 8; i++) pw[i] = pw[i-1] * 3;
      |                                ^
prison.cpp:11:40: error: invalid types 'int[int]' for array subscript
   11 |  for(int i = 1; i <= 8; i++) pw[i] = pw[i-1] * 3;
      |                                        ^
prison.cpp:14:13: error: invalid types 'int[int]' for array subscript
   14 |   if(n >= pw[i] * 2) {n -= pw[i] * 2; which = 2;}
      |             ^
prison.cpp:14:30: error: invalid types 'int[int]' for array subscript
   14 |   if(n >= pw[i] * 2) {n -= pw[i] * 2; which = 2;}
      |                              ^
prison.cpp:15:18: error: invalid types 'int[int]' for array subscript
   15 |   else if(n >= pw[i]) {n -= pw[i]; which = 1;}
      |                  ^
prison.cpp:15:31: error: invalid types 'int[int]' for array subscript
   15 |   else if(n >= pw[i]) {n -= pw[i]; which = 1;}
      |                               ^
prison.cpp: In function 'void build(int, int, int)':
prison.cpp:26:23: error: 'N' was not declared in this scope
   26 |   for(int i = 1; i <= N; i++){
      |                       ^
prison.cpp:40:23: error: 'N' was not declared in this scope
   40 |   for(int i = 1; i <= N; i++){
      |                       ^
prison.cpp:62:22: error: 'N' was not declared in this scope
   62 |  for(int i = 1; i <= N; i++){
      |                      ^