제출 #1274171

#제출 시각아이디문제언어결과실행 시간메모리
1274171jojeonghoonPainting Squares (IOI20_squares)C++20
컴파일 에러
0 ms0 KiB
const int LM=1234, m=1<<9;
vector<int> G[LM], ep;

void dfs(int x){
    while(!G[x].empty()){
        int t=G[x].back();
        G[x].pop_back();
        dfs(t);
    }
    ep.push_back(x);
}

int D[LM];

vector<int> paint(int n){
    vector<int>ret;
    
    for(int i=0; i<m; i++){
        G[i].push_back((i<<1)%m);
        G[i].push_back(((i<<1)+1)%m);
    }
    ep.clear();
    fill(D,D+(1<<10),0);
    dfs(0);
    
    reverse(ep.begin(),ep.end());
    ret.assign(min(9,n), 0);
    
    for(int i=1; i<n-8; i++) ret.push_back(ep[i]%2);
    
    for(int i=0; i<n-10; i++){
        int t=0;
        for(int j=0; j<10; j++) t += ret[i+j]<<j;
        D[t]=i;
    }
    
    ret.push_back(min(10,n));
    
    return ret;
}

int find_location(int n, vector<int>c){
    if(c.back()==-1 || n<10){
        int k=0;
        for(int i:c) k+=i<0;
        return max(n-10, 0)+k;
    }
    
    vector<int>ret;
    
    for(int i=0; i<m; i++){
        G[i].push_back((i<<1)%m);
        G[i].push_back(((i<<1)+1)%m);
    }
    ep.clear();
    fill(D,D+(1<<10),0);
    dfs(0);
    
    reverse(ep.begin(),ep.end());
    ret.assign(min(9,n), 0);
    
    for(int i=1; i<n-8; i++) ret.push_back(ep[i]%2);
    
    for(int i=0; i<n-10; i++){
        int t=0;
        for(int j=0; j<10; j++) t += ret[i+j]<<j;
        D[t]=i;
    }
    
    int t=0;
    for(int i=0; i<10; i++) t+=c[i]<<i;
    return D[t];
}

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

squares.cpp:2:1: error: 'vector' does not name a type
    2 | vector<int> G[LM], ep;
      | ^~~~~~
squares.cpp: In function 'void dfs(int)':
squares.cpp:5:12: error: 'G' was not declared in this scope
    5 |     while(!G[x].empty()){
      |            ^
squares.cpp:10:5: error: 'ep' was not declared in this scope
   10 |     ep.push_back(x);
      |     ^~
squares.cpp: At global scope:
squares.cpp:15:1: error: 'vector' does not name a type
   15 | vector<int> paint(int n){
      | ^~~~~~
squares.cpp:42:26: error: 'vector' has not been declared
   42 | int find_location(int n, vector<int>c){
      |                          ^~~~~~
squares.cpp:42:32: error: expected ',' or '...' before '<' token
   42 | int find_location(int n, vector<int>c){
      |                                ^
squares.cpp: In function 'int find_location(int, int)':
squares.cpp:43:8: error: 'c' was not declared in this scope
   43 |     if(c.back()==-1 || n<10){
      |        ^
squares.cpp:46:16: error: 'max' was not declared in this scope
   46 |         return max(n-10, 0)+k;
      |                ^~~
squares.cpp:49:5: error: 'vector' was not declared in this scope
   49 |     vector<int>ret;
      |     ^~~~~~
squares.cpp:49:12: error: expected primary-expression before 'int'
   49 |     vector<int>ret;
      |            ^~~
squares.cpp:52:9: error: 'G' was not declared in this scope
   52 |         G[i].push_back((i<<1)%m);
      |         ^
squares.cpp:55:5: error: 'ep' was not declared in this scope
   55 |     ep.clear();
      |     ^~
squares.cpp:56:5: error: 'fill' was not declared in this scope
   56 |     fill(D,D+(1<<10),0);
      |     ^~~~
squares.cpp:59:5: error: 'reverse' was not declared in this scope
   59 |     reverse(ep.begin(),ep.end());
      |     ^~~~~~~
squares.cpp:60:5: error: 'ret' was not declared in this scope
   60 |     ret.assign(min(9,n), 0);
      |     ^~~
squares.cpp:60:16: error: 'min' was not declared in this scope
   60 |     ret.assign(min(9,n), 0);
      |                ^~~
squares.cpp:71:32: error: 'c' was not declared in this scope
   71 |     for(int i=0; i<10; i++) t+=c[i]<<i;
      |                                ^