제출 #1177564

#제출 시각아이디문제언어결과실행 시간메모리
1177564alexander707070Robot Contest (IOI23_robot)C++20
82 / 100
124 ms7344 KiB
#include<bits/stdc++.h>
#include "robot.h"

using namespace std;

int states;


int pos(int x){
    if(x>=2 and x<=5)return x;
    if(x>=6 and x<=9)return x-4;
    return 0;
}

void program_pulibot(){
    states=11;

    for(int P=0;P<=states;P++){
        for(int W=-2;W<=states;W++){
            for(int S=-2;S<=states;S++){
                for(int E=-2;E<=states;E++){
                    for(int N=-2;N<=states;N++){

                        if(N==-2 and W==-2 and P==0){
                            set_instruction({P,W,S,E,N},3,'H');
                            continue;
                        }

                        int period=0;
                        if(W>5 or S>5 or E>5 or N>5 or P>5)period=1;

                        if(W==10 or S==10 or E==10 or N==10 or P==10)period=2;

                        if(W==1 or S==1 or E==1 or N==1 or P==1)period=3;
                        if(W==11 or S==11 or E==11 or N==11 or P==11)period=3;

                        if(period==0){

                            if(P==0){
                                if(S==-2 and E==-2){
                                    if(W==4)set_instruction({P,W,S,E,N},2+4,'W');
                                    else if(N==3)set_instruction({P,W,S,E,N},5+4,'N');
                                    else if(E==2)set_instruction({P,W,S,E,N},4+4,'E');
                                    else if(S==5)set_instruction({P,W,S,E,N},3+4,'S'); 
                                    
                                    continue;
                                }
                                
                                if(W==4)set_instruction({P,W,S,E,N},2,'W');
                                else if(N==3)set_instruction({P,W,S,E,N},5,'N');
                                else if(E==2)set_instruction({P,W,S,E,N},4,'E');
                                else if(S==5)set_instruction({P,W,S,E,N},3,'S'); 
    
                                continue;
                            }
    
                            int nxt=P;
                            for(int i=0;i<5;i++){
                                nxt++;
                                if(nxt==6)nxt=2;

                                if(nxt==2 and !(W==0 or W==4))continue;
                                if(nxt==3 and !(S==0 or S==5))continue;
                                if(nxt==4 and !(E==0 or E==2))continue;
                                if(nxt==5 and !(N==0 or N==3))continue;

                                break;
                            }

                            if(nxt==2)set_instruction({P,W,S,E,N},2,'W');
                            if(nxt==3)set_instruction({P,W,S,E,N},3,'S');
                            if(nxt==4)set_instruction({P,W,S,E,N},4,'E');
                            if(nxt==5)set_instruction({P,W,S,E,N},5,'N');

                            continue;
                        }

                        if(period==1){
                            if(N==-2 and W==-2){
                                set_instruction({P,W,S,E,N},10,'H');
                                continue;
                            }

                            int nxt=pos(P);
                            for(int i=0;i<5;i++){
                                nxt++;
                                if(nxt==6)nxt=2;

                                if(nxt==2 and pos(W)!=4)continue;
                                if(nxt==3 and pos(S)!=5)continue;
                                if(nxt==4 and pos(E)!=2)continue;
                                if(nxt==5 and pos(N)!=3)continue;

                                break;
                            }

                            if(nxt==2)set_instruction({P,W,S,E,N},2+4,'W');
                            if(nxt==3)set_instruction({P,W,S,E,N},3+4,'S');
                            if(nxt==4)set_instruction({P,W,S,E,N},4+4,'E');
                            if(nxt==5)set_instruction({P,W,S,E,N},5+4,'N');

                            continue;
                        }
                        
                        if(period==2){
                            if(E==-2 and S==-2){
                                set_instruction({P,W,S,E,N},11,'H');
                                continue;
                            }

                            if(S==9){
                                set_instruction({P,W,S,E,N},10,'S');
                            }else if(N==7){
                                set_instruction({P,W,S,E,N},10,'N');
                            }else if(E==6){
                                set_instruction({P,W,S,E,N},10,'E');
                            }else if(W==8){
                                set_instruction({P,W,S,E,N},10,'W');
                            }else{
                                if(S==10){
                                    set_instruction({P,W,S,E,N},0,'S');
                                }else if(N==10){
                                    set_instruction({P,W,S,E,N},0,'N');
                                }else if(E==10){
                                    set_instruction({P,W,S,E,N},0,'E');
                                }else if(W==10){
                                    set_instruction({P,W,S,E,N},0,'W');
                                }
                            }
                        }

                        if(period==3){

                            if(P>=2 and P<=9){
                                set_instruction({P,W,S,E,N},11,'H');
                            }else if(P==11){
                                if(pos(S)==5)set_instruction({P,W,S,E,N},11,'S');
                                else if(pos(W)==4)set_instruction({P,W,S,E,N},11,'W');
                                else if(pos(E)==2)set_instruction({P,W,S,E,N},11,'E');
                                else if(pos(N)==3)set_instruction({P,W,S,E,N},11,'N');
                                else{
                                    if(S==11)set_instruction({P,W,S,E,N},0,'S');
                                    else if(W==11)set_instruction({P,W,S,E,N},0,'W');
                                    else if(E==11)set_instruction({P,W,S,E,N},0,'E');
                                    else if(N==11)set_instruction({P,W,S,E,N},0,'N');
                                    else set_instruction({P,W,S,E,N},1,'H');
                                }
                            }else if(P==10){
                                set_instruction({P,W,S,E,N},11,'H');
                            }else if(P==1){
                                if(N==-2 and W==-2)set_instruction({P,W,S,E,N},1,'T');
                                else{
                                    if(S==10)set_instruction({P,W,S,E,N},1,'S');
                                    else if(W==10)set_instruction({P,W,S,E,N},1,'W');
                                    else if(E==10)set_instruction({P,W,S,E,N},1,'E');
                                    else if(N==10)set_instruction({P,W,S,E,N},1,'N');
                                }
                            }
                        }
                    }
                }
            }
        }
    }

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...