제출 #1177555

#제출 시각아이디문제언어결과실행 시간메모리
1177555alexander707070로봇 대회 (IOI23_robot)C++20
17 / 100
75 ms6740 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=9;

    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==1 or S==1 or E==1 or N==1 or P==1)period=2;

                        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(S==2)set_instruction({P,W,S,E,N},4+4,'E');
                                    else if(E==5)set_instruction({P,W,S,E,N},3+4,'S'); 
                                    
                                    continue;
                                }
                                
                                if(pos(W)==4)set_instruction({P,W,S,E,N},2,'W');
                                else if(pos(N)==3)set_instruction({P,W,S,E,N},5,'N');
                                else if(pos(E)==2)set_instruction({P,W,S,E,N},4,'E');
                                else if(pos(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)continue;
                                if(nxt==3 and S<0)continue;
                                if(nxt==4 and E<0)continue;
                                if(nxt==5 and N<0)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},1,'H');
                                continue;
                            }

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

                                if(nxt==2 and W<=0)continue;
                                if(nxt==3 and S<=0)continue;
                                if(nxt==4 and E<=0)continue;
                                if(nxt==5 and N<=0)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},1,'T');
                                continue;
                            }

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

}
#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...