Submission #1133677

#TimeUsernameProblemLanguageResultExecution timeMemory
1133677KhoaDuyNavigation 2 (JOI21_navigation2)C++20
Compilation error
0 ms0 KiB
void Anna(int n,int k,vector<int> r,vector<int> c){
    int pos[3][3];
    memset(pos,0,sizeof(pos));
    for(int i=0;i<k;i++){
        pos[r[i]%3][c[i]%3]=1;
    }
    vector<pair<int,int>> unuse;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(pos[i][j]==0&&unuse.size()<2){
                unuse.push_back({i,j});
            }
            else{
                pos[i][j]=1;
            }
        }
    }
    int dx[]={-1,-1,0,1};
    int dy[]={0,1,1,1};
    for(int k=0;k<4;k++){
        if(unuse.back().first+dx[k]==unuse[0].first&&unuse.back().second+dy[k]==unuse[0].second){
            swap(unuse[0],unuse[1]);
            break;
        }
    }
    int ptr=0;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            int x=unuse[0].first+i,y=unuse[0].second+j;
            x%=3,y%=3;
            if(pos[x][y]==0){
                for(int a=x;a<n;a+=3){
                    for(int b=y;b<n;b+=3){
                        SetFlag(a,b,12);
                    }
                }
                continue;
            }
            ptr++;
            pos[x][y]=ptr;
        }
    }
    ptr=0;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            int x=unuse[0].first+i,y=unuse[0].second+j;
            x%=3,y%=3;
            if(pos[x][y]==0){
                continue;
            }
            for(int a=x;a<n;a+=3){
                for(int b=y;b<n;b+=3){
                    if(abs(a-r[ptr])<=1&&abs(b-c[ptr])<=1){
                        SetFlag(a,b,pos[r[ptr]%3][c[ptr]%3]);
                    }
                    else{
                        int val=-9;
                        if(b-1>c[ptr]){
                            val=1;
                        }
                        else if(a-1>r[ptr]){
                            val=3;
                        }
                        else if(b+1<c[ptr]){
                            val=0;
                        }
                        else if(a+1<r[ptr]){
                            val=2;
                        }
                        val+=8;
                        SetFlag(a,b,val);
                    }
                }
            }
            ptr++;
        }
    }
}
vector<int> Bruno(int k,vector<int> value){
    vector<int> ans;
    vector<pair<int,int>> unuse;
    int pos[3][3];
    memset(pos,0,sizeof(pos));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(value[i*3+j]==12){
                unuse.push_back({i,j});
            }
            else{
                pos[i][j]=1;
            }
        }
    }
    int dx[]={-1,-1,0,1};
    int dy[]={0,1,1,1};
    for(int k=0;k<4;k++){
        if(unuse.back().first+dx[k]==unuse[0].first&&unuse.back().second+dy[k]==unuse[0].second){
            swap(unuse[0],unuse[1]);
            break;
        }
    }
    vector<pair<int,int>> convert;
    convert.push_back({-1,-1});
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            int x=unuse[0].first+i,y=unuse[0].second+j;
            x%=3,y%=3;
            if(pos[x][y]!=0){
                convert.push_back({x,y});
            }
        }
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            int x=unuse[0].first+i,y=unuse[0].second+j;
            x%=3,y%=3;
            if(pos[x][y]==0){
                continue;
            }
            if(value[x*3+y]>=8){
                ans.push_back(value[x*3+y]-8);
                continue;
            }
            int x2=convert[value[x*3+y]].first,y2=convert[value[x*3+y]].second;
            while(x2-x>=2){
                x2-=3;
            }
            while(x-x2>=2){
                x2+=3;
            }
            while(y2-y>=2){
                y2-=3;
            }
            while(y-y2>=2){
                y2+=3;
            }
            if(y2>1){
                ans.push_back(0);
            }
            else if(y2<1){
                ans.push_back(1);
            }
            else if(x2>1){
                ans.push_back(2);
            }
            else if(x2<1){
                ans.push_back(3);
            }
            else{
                ans.push_back(4);
            }
        }
    }
    return ans;
}

Compilation message (stderr)

# 1번째 컴파일 단계

Anna.cpp:1:23: error: 'vector' has not been declared
    1 | void Anna(int n,int k,vector<int> r,vector<int> c){
      |                       ^~~~~~
Anna.cpp:1:29: error: expected ',' or '...' before '<' token
    1 | void Anna(int n,int k,vector<int> r,vector<int> c){
      |                             ^
Anna.cpp: In function 'void Anna(int, int, int)':
Anna.cpp:3:5: error: 'memset' was not declared in this scope
    3 |     memset(pos,0,sizeof(pos));
      |     ^~~~~~
Anna.cpp:1:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
  +++ |+#include <cstring>
    1 | void Anna(int n,int k,vector<int> r,vector<int> c){
Anna.cpp:5:13: error: 'r' was not declared in this scope
    5 |         pos[r[i]%3][c[i]%3]=1;
      |             ^
Anna.cpp:5:21: error: 'c' was not declared in this scope
    5 |         pos[r[i]%3][c[i]%3]=1;
      |                     ^
Anna.cpp:7:12: error: 'pair' was not declared in this scope
    7 |     vector<pair<int,int>> unuse;
      |            ^~~~
Anna.cpp:7:5: error: 'vector' was not declared in this scope
    7 |     vector<pair<int,int>> unuse;
      |     ^~~~~~
Anna.cpp:7:17: error: expected primary-expression before 'int'
    7 |     vector<pair<int,int>> unuse;
      |                 ^~~
Anna.cpp:10:30: error: 'unuse' was not declared in this scope
   10 |             if(pos[i][j]==0&&unuse.size()<2){
      |                              ^~~~~
Anna.cpp:21:12: error: 'unuse' was not declared in this scope
   21 |         if(unuse.back().first+dx[k]==unuse[0].first&&unuse.back().second+dy[k]==unuse[0].second){
      |            ^~~~~
Anna.cpp:22:13: error: 'swap' was not declared in this scope
   22 |             swap(unuse[0],unuse[1]);
      |             ^~~~
Anna.cpp:29:19: error: 'unuse' was not declared in this scope
   29 |             int x=unuse[0].first+i,y=unuse[0].second+j;
      |                   ^~~~~
Anna.cpp:30:18: error: 'y' was not declared in this scope
   30 |             x%=3,y%=3;
      |                  ^
Anna.cpp:34:25: error: 'SetFlag' was not declared in this scope
   34 |                         SetFlag(a,b,12);
      |                         ^~~~~~~
Anna.cpp:46:19: error: 'unuse' was not declared in this scope
   46 |             int x=unuse[0].first+i,y=unuse[0].second+j;
      |                   ^~~~~
Anna.cpp:47:18: error: 'y' was not declared in this scope
   47 |             x%=3,y%=3;
      |                  ^
Anna.cpp:53:30: error: 'r' was not declared in this scope
   53 |                     if(abs(a-r[ptr])<=1&&abs(b-c[ptr])<=1){
      |                              ^
Anna.cpp:53:24: error: 'abs' was not declared in this scope
   53 |                     if(abs(a-r[ptr])<=1&&abs(b-c[ptr])<=1){
      |                        ^~~
Anna.cpp:53:48: error: 'c' was not declared in this scope
   53 |                     if(abs(a-r[ptr])<=1&&abs(b-c[ptr])<=1){
      |                                                ^
Anna.cpp:54:25: error: 'SetFlag' was not declared in this scope
   54 |                         SetFlag(a,b,pos[r[ptr]%3][c[ptr]%3]);
      |                         ^~~~~~~
Anna.cpp:71:25: error: 'SetFlag' was not declared in this scope
   71 |                         SetFlag(a,b,val);
      |                         ^~~~~~~