제출 #763541

#제출 시각아이디문제언어결과실행 시간메모리
763541raysh07죄수들의 도전 (IOI22_prison)C++17
컴파일 에러
0 ms0 KiB
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;

const int a = {2501, 834, 279, 94, 32, 11, 4, 1};
const int mv[22];
const int v[22];

int get(int x, int b){
    for (int i = 0; i < b; i++){
        x %= a[i];
    }
    
    return x / a[b];
}
 
vector<vector<int>> devise_strategy(int n) {
    vector<vector<int>> ans(22, vector<int>(n + 1));
    
    mv[0] = 0;
    mv[1] = mv[2] = 0;
    mv[3] = mv[4] = mv[5] = 1;
    mv[6] = mv[7] = mv[8] = 2;
    mv[9] = mv[10] = mv[11] = 3;
    mv[12] = mv[13] = mv[14] = 4;
    mv[15] = mv[16] = mv[17] = 5;
    mv[18] = mv[19] = mv[20] = 6;
    mv[21] = 7;
    
    v[1] = v[3] = v[6] = v[9] = v[12] = v[15] = v[18] = 0;
    v[2] = v[4] = v[7] = v[10] = v[13] = v[16] = v[19] = 1;
    v[5] = v[8] = v[11] = v[14] = v[17] = v[20] = 2;
    
    for (int i = 0; i <= 21; i++){
        if (i == 0){
            ans[i][0] = 0;
            for (int j = 1; j <= n; j++){
                ans[i][j] = 1 + get(j, mv[i]);
            }
            continue;
        } else if (i == 21){
            ans[i][0] = 0;
            for (int j = 1; j <= n; j++){
                int x = get(j, mv[i]);
                if (x <= 1) ans[i][j] = -1;
                else ans[i][j] = -2;
            }
            continue;
        } else if (i <= 2){
            ans[i][0] = 1;
            for (int j = 1; j <= n; j++){
                int bb = get(j, mv[i]);
                int aa = v[i];
                
                if (aa < bb) ans[i][j] = -1;
                else if (aa > bb) ans[i][j] = -2;
                else ans[i][j] = 3 + get(j, mv[i] + 1);
            }
            continue;
        } else if (i >= 18){
            ans[i][0] = 1;
            for (int j = 1; j <= n; j++){
                int bb = get(j, mv[i]);
                int aa = v[i];
                
                if (aa < bb) ans[i][j] = -1;
                else if (aa > bb) ans[i][j] = -2;
                else {
                    int gg = get(j, mv[i] + 1);
                    if (gg == 0) ans[i][j] = -2;
                    else if (gg == 3) ans[i][j] = -3;
                    else ans[i][j] = 21;
                }
            }
            continue;
        }
        
        if (mv[i] & 1){
            //B's move
            ans[i][0] = 1;
            for (int j = 1; j <= n; j++){
                int bb = get(j, mv[i]);
                int aa = v[i];
                
                if (aa < bb) ans[i][j] = -1;
                else if (aa > bb) ans[i][j] = -2;
                else ans[i][j] = i - v[i] + 3 + get(j, mv[i] + 1);
            }
        } else {
            //A's move 
            ans[i][0] = 0;
            for (int j = 1; j <= n; j++){
                int aa = get(j, mv[i]);
                int bb = v[i];
                
                if (aa < bb) ans[i][j] = -1;
                else if (aa > bb) ans[i][j] = -2;
                else ans[i][j] = i - v[i] + 3 + get(j, mv[i] + 1);
            }
        }
    }
    
    // for (auto x : ans){
    //     for (auto y : x ) cout << y << " ";
    //     cout << "\n";
    // }
    
    // for (int i = 0; i <= x; i++){
    //     cout << i << " ";
    //     for (int j = 0; j <= n; j++){
    //         cout << ans[i][j] << " ";
    //     }
    // }
    return ans;
}

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

prison.cpp:5:11: error: scalar object 'a' requires one element in initializer
    5 | const int a = {2501, 834, 279, 94, 32, 11, 4, 1};
      |           ^
prison.cpp:6:11: error: uninitialized 'const mv' [-fpermissive]
    6 | const int mv[22];
      |           ^~
prison.cpp:7:11: error: uninitialized 'const v' [-fpermissive]
    7 | const int v[22];
      |           ^
prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:20:11: error: assignment of read-only location 'mv[0]'
   20 |     mv[0] = 0;
      |     ~~~~~~^~~
prison.cpp:21:19: error: assignment of read-only location 'mv[2]'
   21 |     mv[1] = mv[2] = 0;
      |             ~~~~~~^~~
prison.cpp:22:27: error: assignment of read-only location 'mv[5]'
   22 |     mv[3] = mv[4] = mv[5] = 1;
      |                     ~~~~~~^~~
prison.cpp:23:27: error: assignment of read-only location 'mv[8]'
   23 |     mv[6] = mv[7] = mv[8] = 2;
      |                     ~~~~~~^~~
prison.cpp:24:29: error: assignment of read-only location 'mv[11]'
   24 |     mv[9] = mv[10] = mv[11] = 3;
      |                      ~~~~~~~^~~
prison.cpp:25:30: error: assignment of read-only location 'mv[14]'
   25 |     mv[12] = mv[13] = mv[14] = 4;
      |                       ~~~~~~~^~~
prison.cpp:26:30: error: assignment of read-only location 'mv[17]'
   26 |     mv[15] = mv[16] = mv[17] = 5;
      |                       ~~~~~~~^~~
prison.cpp:27:30: error: assignment of read-only location 'mv[20]'
   27 |     mv[18] = mv[19] = mv[20] = 6;
      |                       ~~~~~~~^~~
prison.cpp:28:12: error: assignment of read-only location 'mv[21]'
   28 |     mv[21] = 7;
      |     ~~~~~~~^~~
prison.cpp:30:55: error: assignment of read-only location 'v[18]'
   30 |     v[1] = v[3] = v[6] = v[9] = v[12] = v[15] = v[18] = 0;
      |                                                 ~~~~~~^~~
prison.cpp:31:56: error: assignment of read-only location 'v[19]'
   31 |     v[2] = v[4] = v[7] = v[10] = v[13] = v[16] = v[19] = 1;
      |                                                  ~~~~~~^~~
prison.cpp:32:49: error: assignment of read-only location 'v[20]'
   32 |     v[5] = v[8] = v[11] = v[14] = v[17] = v[20] = 2;
      |                                           ~~~~~~^~~