Submission #1010130

#TimeUsernameProblemLanguageResultExecution timeMemory
1010130UnforgettableplNavigation 2 (JOI21_navigation2)C++17
85 / 100
621 ms1708 KiB
#include "Anna.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;


namespace {

vector<vector<int>> assignment = {
    {0,1,2},
    {3,4,5},
    {6,7,7},
};

} // namespace

void Anna(int N, int K, std::vector<int> R, std::vector<int> C) {
    int offset_x=0;
    int offset_y=0;
    vector<vector<int>> flags(N,vector<int>(N));
    re:
    assert(offset_x!=3);
    for (int r = 0; r < N; r++) {
        for (int c = 0; c < N; c++) {
            if(assignment[(r+offset_x)%3][(c+offset_y)%3]==7){flags[r][c]=(r,c,13);continue;}
            auto ass = assignment[(r+offset_x)%3][(c+offset_y)%3];
            if(abs(R[ass]-r)<=1 and abs(C[ass]-c)<=1){
                if(R[ass]==r and C[ass]==c){
                    // Redo
                    if(offset_y==2){
                        offset_x++;
                        offset_y=0;
                    } else offset_y++;
                    goto re;
                }
                else if(R[ass]==r-1 and C[ass]==c)flags[r][c]=(r,c,12);
                else if(R[ass]==r-1 and C[ass]==c-1)flags[r][c]=(r,c,11);
                else if(R[ass]==r-1 and C[ass]==c+1)flags[r][c]=(r,c,5);
                else if(R[ass]==r and C[ass]==c-1)flags[r][c]=(r,c,10);
                else if(R[ass]==r and C[ass]==c+1)flags[r][c]=(r,c,6);
                else if(R[ass]==r+1 and C[ass]==c-1)flags[r][c]=(r,c,9);
                else if(R[ass]==r+1 and C[ass]==c)flags[r][c]=(r,c,8);
                else if(R[ass]==r+1 and C[ass]==c+1)flags[r][c]=(r,c,7);
                continue;
            }
            if(abs(R[ass]-r)<=1){
                if(c<C[ass])flags[r][c]=(r,c,2);
                else if(C[ass]<c)flags[r][c]=(r,c,4);
                continue;
            }
            if(r<R[ass])flags[r][c]=(r,c,3);
            else if(R[ass]<r)flags[r][c]=(r,c,1);
        }
    }
    for(int i=0;i<N;i++)for(int j=0;j<N;j++)SetFlag(i,j,flags[i][j]);
}
#include "Bruno.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;


namespace {

vector<pair<int,int>> idxlookup = {
    {0,0},
    {0,1},
    {0,2},
    {1,0},
    {1,1},
    {1,2},
    {2,0},
};

} // namespace

std::vector<int> Bruno(int K, std::vector<int> value) {
    vector<vector<int>> val = {
        {value[0],value[1],value[2]},
        {value[3],value[4],value[5]},
        {value[6],value[7],value[8]},
    };
    vector<int> ans(K, 0);
    int rowoffset = 0;
    if(val[0][0]==13 or val[0][1]==13 or val[0][2]==13)rowoffset=1;
    if(val[1][0]==13 or val[1][1]==13 or val[1][2]==13)rowoffset=2;
    if(val[2][0]==13 or val[2][1]==13 or val[2][2]==13)rowoffset=0;
    int coloffset = 0;
    if(val[(rowoffset+2)%3][1]==13 and val[(rowoffset+2)%3][2]==13)coloffset=0;
    if(val[(rowoffset+2)%3][0]==13 and val[(rowoffset+2)%3][1]==13)coloffset=2;
    if(val[(rowoffset+2)%3][0]==13 and val[(rowoffset+2)%3][2]==13)coloffset=1;
    for(int i=0;i<K;i++){
        int act_x = (idxlookup[i].first+rowoffset)%3;
        int act_y = (idxlookup[i].second+coloffset)%3;
        if(val[act_x][act_y]==1){ans[i]=3;continue;}
        if(val[act_x][act_y]==2){ans[i]=0;continue;}
        if(val[act_x][act_y]==3){ans[i]=2;continue;}
        if(val[act_x][act_y]==4){ans[i]=1;continue;}
        int where_x = act_x;
        int where_y = act_y;
        if(val[act_x][act_y]==12){where_x+=-1;where_y+=0;}
        if(val[act_x][act_y]==11){where_x+=-1;where_y+=-1;}
        if(val[act_x][act_y]==10){where_x+=0;where_y+=-1;}
        if(val[act_x][act_y]==6){where_x+=0;where_y+=1;}
        if(val[act_x][act_y]==5){where_x+=-1;where_y+=1;}
        if(val[act_x][act_y]==9){where_x+=1;where_y+=-1;}
        if(val[act_x][act_y]==8){where_x+=1;where_y+=0;}
        if(val[act_x][act_y]==7){where_x+=1;where_y+=1;}
        if(where_x==1 and where_y==1){ans[i]=4;continue;}
        if(where_x<1){ans[i]=3;continue;}
        if(where_x>1){ans[i]=2;continue;}
        if(where_y<1){ans[i]=1;continue;}
        if(where_y>1){ans[i]=0;continue;}
    }
    return ans;
}

Compilation message (stderr)

Anna.cpp: In function 'void Anna(int, int, std::vector<int>, std::vector<int>)':
Anna.cpp:25:76: warning: left operand of comma operator has no effect [-Wunused-value]
   25 |             if(assignment[(r+offset_x)%3][(c+offset_y)%3]==7){flags[r][c]=(r,c,13);continue;}
      |                                                                            ^
Anna.cpp:25:80: warning: right operand of comma operator has no effect [-Wunused-value]
   25 |             if(assignment[(r+offset_x)%3][(c+offset_y)%3]==7){flags[r][c]=(r,c,13);continue;}
      |                                                                                ^~
Anna.cpp:36:64: warning: left operand of comma operator has no effect [-Wunused-value]
   36 |                 else if(R[ass]==r-1 and C[ass]==c)flags[r][c]=(r,c,12);
      |                                                                ^
Anna.cpp:36:68: warning: right operand of comma operator has no effect [-Wunused-value]
   36 |                 else if(R[ass]==r-1 and C[ass]==c)flags[r][c]=(r,c,12);
      |                                                                    ^~
Anna.cpp:37:66: warning: left operand of comma operator has no effect [-Wunused-value]
   37 |                 else if(R[ass]==r-1 and C[ass]==c-1)flags[r][c]=(r,c,11);
      |                                                                  ^
Anna.cpp:37:70: warning: right operand of comma operator has no effect [-Wunused-value]
   37 |                 else if(R[ass]==r-1 and C[ass]==c-1)flags[r][c]=(r,c,11);
      |                                                                      ^~
Anna.cpp:38:66: warning: left operand of comma operator has no effect [-Wunused-value]
   38 |                 else if(R[ass]==r-1 and C[ass]==c+1)flags[r][c]=(r,c,5);
      |                                                                  ^
Anna.cpp:38:70: warning: right operand of comma operator has no effect [-Wunused-value]
   38 |                 else if(R[ass]==r-1 and C[ass]==c+1)flags[r][c]=(r,c,5);
      |                                                                      ^
Anna.cpp:39:64: warning: left operand of comma operator has no effect [-Wunused-value]
   39 |                 else if(R[ass]==r and C[ass]==c-1)flags[r][c]=(r,c,10);
      |                                                                ^
Anna.cpp:39:68: warning: right operand of comma operator has no effect [-Wunused-value]
   39 |                 else if(R[ass]==r and C[ass]==c-1)flags[r][c]=(r,c,10);
      |                                                                    ^~
Anna.cpp:40:64: warning: left operand of comma operator has no effect [-Wunused-value]
   40 |                 else if(R[ass]==r and C[ass]==c+1)flags[r][c]=(r,c,6);
      |                                                                ^
Anna.cpp:40:68: warning: right operand of comma operator has no effect [-Wunused-value]
   40 |                 else if(R[ass]==r and C[ass]==c+1)flags[r][c]=(r,c,6);
      |                                                                    ^
Anna.cpp:41:66: warning: left operand of comma operator has no effect [-Wunused-value]
   41 |                 else if(R[ass]==r+1 and C[ass]==c-1)flags[r][c]=(r,c,9);
      |                                                                  ^
Anna.cpp:41:70: warning: right operand of comma operator has no effect [-Wunused-value]
   41 |                 else if(R[ass]==r+1 and C[ass]==c-1)flags[r][c]=(r,c,9);
      |                                                                      ^
Anna.cpp:42:64: warning: left operand of comma operator has no effect [-Wunused-value]
   42 |                 else if(R[ass]==r+1 and C[ass]==c)flags[r][c]=(r,c,8);
      |                                                                ^
Anna.cpp:42:68: warning: right operand of comma operator has no effect [-Wunused-value]
   42 |                 else if(R[ass]==r+1 and C[ass]==c)flags[r][c]=(r,c,8);
      |                                                                    ^
Anna.cpp:43:66: warning: left operand of comma operator has no effect [-Wunused-value]
   43 |                 else if(R[ass]==r+1 and C[ass]==c+1)flags[r][c]=(r,c,7);
      |                                                                  ^
Anna.cpp:43:70: warning: right operand of comma operator has no effect [-Wunused-value]
   43 |                 else if(R[ass]==r+1 and C[ass]==c+1)flags[r][c]=(r,c,7);
      |                                                                      ^
Anna.cpp:47:42: warning: left operand of comma operator has no effect [-Wunused-value]
   47 |                 if(c<C[ass])flags[r][c]=(r,c,2);
      |                                          ^
Anna.cpp:47:46: warning: right operand of comma operator has no effect [-Wunused-value]
   47 |                 if(c<C[ass])flags[r][c]=(r,c,2);
      |                                              ^
Anna.cpp:48:47: warning: left operand of comma operator has no effect [-Wunused-value]
   48 |                 else if(C[ass]<c)flags[r][c]=(r,c,4);
      |                                               ^
Anna.cpp:48:51: warning: right operand of comma operator has no effect [-Wunused-value]
   48 |                 else if(C[ass]<c)flags[r][c]=(r,c,4);
      |                                                   ^
Anna.cpp:51:38: warning: left operand of comma operator has no effect [-Wunused-value]
   51 |             if(r<R[ass])flags[r][c]=(r,c,3);
      |                                      ^
Anna.cpp:51:42: warning: right operand of comma operator has no effect [-Wunused-value]
   51 |             if(r<R[ass])flags[r][c]=(r,c,3);
      |                                          ^
Anna.cpp:52:43: warning: left operand of comma operator has no effect [-Wunused-value]
   52 |             else if(R[ass]<r)flags[r][c]=(r,c,1);
      |                                           ^
Anna.cpp:52:47: warning: right operand of comma operator has no effect [-Wunused-value]
   52 |             else if(R[ass]<r)flags[r][c]=(r,c,1);
      |                                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...