Submission #919695

#TimeUsernameProblemLanguageResultExecution timeMemory
919695alexander707070Navigation 2 (JOI21_navigation2)C++17
75 / 100
509 ms2708 KiB
#include<bits/stdc++.h>
#include "Anna.h"
using namespace std;
 
namespace{
int n;
vector< pair<int,int> > calc={ {0,0},{0,1},{0,2},{1,0},{1,1},{1,2},{2,0} };

void flag(int x,int y,int c){
  if(x>=0 and x<n and y>=0 and y<n)SetFlag(x,y,c);
}

}
 
void Anna(int N, int K, vector<int> R, vector<int> C) {
    n=N;

    for(int t=0;t<K;t++){
        for(int i=0;i<N;i+=3){
            for(int f=0;f<N;f+=3){
                if(R[t]<i+calc[t].first-1)flag(i+calc[t].first,f+calc[t].second,1);
                else if(R[t]>i+calc[t].first+1)flag(i+calc[t].first,f+calc[t].second,2);
                else if(C[t]<f+calc[t].second-1)flag(i+calc[t].first,f+calc[t].second,3);
                else if(C[t]>f+calc[t].second+1)flag(i+calc[t].first,f+calc[t].second,4);
                else{
                    if(R[t]==i+calc[t].first-1 and C[t]==f+calc[t].second-1)flag(i+calc[t].first,f+calc[t].second,5);
                    if(R[t]==i+calc[t].first-1 and C[t]==f+calc[t].second-0)flag(i+calc[t].first,f+calc[t].second,6);
                    if(R[t]==i+calc[t].first-1 and C[t]==f+calc[t].second+1)flag(i+calc[t].first,f+calc[t].second,7);

                    if(R[t]==i+calc[t].first-0 and C[t]==f+calc[t].second-1)flag(i+calc[t].first,f+calc[t].second,8);
                    if(R[t]==i+calc[t].first-0 and C[t]==f+calc[t].second-0)flag(i+calc[t].first,f+calc[t].second,9);
                    if(R[t]==i+calc[t].first-0 and C[t]==f+calc[t].second+1)flag(i+calc[t].first,f+calc[t].second,10);

                    if(R[t]==i+calc[t].first+1 and C[t]==f+calc[t].second-1)flag(i+calc[t].first,f+calc[t].second,11);
                    if(R[t]==i+calc[t].first+1 and C[t]==f+calc[t].second-0)flag(i+calc[t].first,f+calc[t].second,12);
                    if(R[t]==i+calc[t].first+1 and C[t]==f+calc[t].second+1)flag(i+calc[t].first,f+calc[t].second,13);
                }
            }
        }
    }
 
    for(int i=0;i<N;i+=3){
        for(int f=0;f<N;f+=3){
            flag(i+2,f+1,14);
            flag(i+2,f+2,14);
        }
    }
}
#include<bits/stdc++.h>
#include "Bruno.h"
using namespace std;
 
namespace{
int table[4][4],to[4][4];
int x,y;
 
int sampl[8][8];
vector<int> sol;
}
 
vector<int> Bruno(int K, vector<int> value) {

    sol.clear();

    for(int i=1;i<=6;i+=3){
        for(int f=1;f<=6;f+=3){
            sampl[i][f]=1;
            sampl[i][f+1]=2;
            sampl[i][f+2]=3;
 
            sampl[i+1][f]=4;
            sampl[i+1][f+1]=5;
            sampl[i+1][f+2]=6;
 
            sampl[i+2][f]=7;
            sampl[i+2][f+1]=-1;
            sampl[i+2][f+2]=-1;
        }
    }
 
    for(int i=0;i<value.size();i++){
        table[i/3+1][i%3+1]=value[i];
    }
 
    for(int i=1;i<=3;i++){
        for(int f=1;f<=3;f++){
            bool dali=true;
 
            for(int k=1;k<=3;k++){
                for(int t=1;t<=3;t++){
                    if(table[k][t]==14 and sampl[i+k-1][f+t-1]!=-1)dali=false;
                }
            }
 
            if(!dali)continue;
 
            for(int k=1;k<=3;k++){
                for(int t=1;t<=3;t++){
                    to[k][t]=sampl[i+k-1][f+t-1];
                }
            }
        }
    }
 
    for(int t=1;t<=K;t++){
        int res=0,x=0,y=0,ans=0;
 
        for(int i=1;i<=3;i++){
            for(int f=1;f<=3;f++){
                if(to[i][f]==t){
                    res=table[i][f];
                    x=i-2; y=f-2;
                }
            }
        }
 
        if(res==1)ans=3;
        else if(res==2)ans=2;
        else if(res==3)ans=1;
        else if(res==4)ans=0;
        else{
            if(res==5){x=-1+x;y=-1+y;}
            if(res==6){x=-1+x;y=0+y;}
            if(res==7){x=-1+x;y=1+y;}
 
            if(res==8){x=0+x;y=-1+y;}
            if(res==9){x=0+x;y=0+y;}
            if(res==10){x=0+x;y=1+y;}
 
            if(res==11){x=1+x;y=-1+y;}
            if(res==12){x=1+x;y=0+y;}
            if(res==13){x=1+x;y=1+y;}
 
            if(x<0)ans=3;
            else if(x>0)ans=2;
            else if(y<0)ans=1;
            else if(y>0)ans=0;
            else ans=4;
        }

        sol.push_back(ans);
    }
 
    return sol;
 
}
 
/*
1
10 7
1 4
2 7
3 1
4 6
5 3
6 2
7 5
2 7
*/

Compilation message (stderr)

Bruno.cpp: In function 'std::vector<int> Bruno(int, std::vector<int>)':
Bruno.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0;i<value.size();i++){
      |                 ~^~~~~~~~~~~~~
Bruno.cpp: At global scope:
Bruno.cpp:7:7: warning: '{anonymous}::y' defined but not used [-Wunused-variable]
    7 | int x,y;
      |       ^
Bruno.cpp:7:5: warning: '{anonymous}::x' defined but not used [-Wunused-variable]
    7 | int x,y;
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...