Submission #938148

#TimeUsernameProblemLanguageResultExecution timeMemory
938148AdamGSRobot Contest (IOI23_robot)C++17
88 / 100
106 ms7640 KiB
#include "robot.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
void guwno(vector<int>S) {
    char D[]={'W', 'S', 'E', 'N'};
    if(S[0]==1 || S[0]==9) {
        rep(i, 4) if(S[i+1]==(i+2)%4+2) {
            set_instruction(S, S[0], D[i]);
            return;
        }
        if(S[1]==-2 && S[4]==-2) {
            set_instruction(S, 1, 'T');
            return;
        }
    }
    if(S[0]==1) {
        rep(i, 4) if(6<=S[i+1] && S[i+1]<=8) {
            set_instruction(S, 1, D[i]);
            return;
        }
        return;
    }
    if(S[0]==9) {
        rep(i, 4) if(S[i+1]==9) {
            set_instruction(S, 0, D[i]);
            return;
        }
        if(S[1]==-2 && S[4]==1) {
            set_instruction(S, 0, 'N');
            return;
        }
        if(S[4]==-2 && S[1]==1) {
            set_instruction(S, 0, 'W');
            return;
        }
        set_instruction(S, 1, 'H');
        return;
    }
    if(S[1]==-2 && S[4]==-2) {
        // jestem w (0, 0) 
        // 6 oznaczalo ze szedlem w dol
        // 7 oznaczalo ze szedlem w prawo
        if(S[0]==0) {
            // jestem na samym poczatku programu
            if(S[2]!=0) {
                set_instruction(S, 6, 'H');
                return;
            }
            set_instruction(S, 6, 'S');
            return;
        }
        rep(i, 4) if(S[i+1]==1) {
            set_instruction(S, 1, 'H');
            return;
        }
        if(S[0]==6) {
            if(S[3]==0 || S[3]==2) {
                set_instruction(S, 7, 'E');
                return;
            }
            set_instruction(S, 7, 'H');
            return;
        }
        if(S[0]==7) {
            if(S[2]==0 || S[2]==5) {
                set_instruction(S, 6, 'S');
                return;
            }
            set_instruction(S, 6, 'H');
            return;
        }
        return;
    }
    if(S[2]==-2 && S[3]==-2) {
        // jestem w (H-1, W-1) i zaczynam wracac sciezka 6-8
        if(6<=S[4] && S[4]<=8) {
            set_instruction(S, 9, 'H');
            return;
        }
        if(6<=S[1] && S[1]<=8) {
            set_instruction(S, 9, 'H');
            return;
        }
        return;
    }
    if(2<=S[0] && S[0]<=5) {
        if(S[S[0]-1]==1 || S[S[0]-1]==9) {
            set_instruction(S, 9, 'H');
            return;
        }
    }
    // patrze czy ktos kolo mnie ma juz 1 i sam tez sie ustawiam
    rep(i, 4) if(S[i+1]==1) {
        rep(j, 4) if(6<=S[j+1] && S[j+1]<=8) {
            set_instruction(S, 9, 'H');
            return;
        }
        return;
    }
    // jesli jestem 0 to znaczy ze musze zaznaczyc sobie strzalke i wrocic
    // jesli jestem strzalka to znaczy ze musze zaznaczyc sie na 6 i isc w strone o 1 dalej niz strzalka
    // jesli jestem 6 lub 7 to zaznaczam sie na kolejne i tez ide dalej wzgledem ostatniego
    // jesli jestem 8 to zaznaczam sobie strzalke i wracam
    if(S[0]==0) {
        rep(i, 4) if(6<=S[i+1] && S[i+1]<=8) {
            set_instruction(S, i+2, D[i]);
            return;
        }
        return;
    }
    if(2<=S[0] && S[0]<=5) {
        rep(i, 4) if(6<=S[i+1] && S[i+1]<=8) {
            int p=(i+1)%4;
            if(S[p+1]==0 || S[p+1]==(p+2)%4+2) {
                set_instruction(S, 6, D[p]);
                return;
            }
            set_instruction(S, 6, 'H');
            return;
        }
        return;
    }
    if(S[0]==6 || S[0]==7) {
        rep(i, 4) if(6<=S[i+1] && S[i+1]<=8) {
            int p=(i+S[0]-4)%4;
            if(S[p+1]==0 || S[p+1]==(p+2)%4+2) {
                set_instruction(S, S[0]+1, D[p]);
                return;
            }
            set_instruction(S, S[0]+1, 'H');
            return;
        }
        return;
    }
    if(S[0]==8) {
        rep(i, 4) if(6<=S[i+1] && S[i+1]<=8) {
            set_instruction(S, i+2, D[i]);
            return;
        }
        return;
    }
}
void program_pulibot() {
    int z=9;
    rep(a, z+3) rep(b, z+3) rep(c, z+3) rep(d, z+3) rep(e, z+3) guwno({a-2, b-2, c-2, d-2, e-2});
}
// -2 - sciana
// -1 - blokada
// 0 - nie odwiedzony
// 1 - sciezka 
// 2,3,4,5 - WSEN
// 6,7,8 - iteratory DFS

// optymalizacja na full:
// jesli jestem strzalka i pokazuje na 1 lub 9 to zmieniam sie w 9
// jesli jestem w 1 to patrze na boki czy nie ma strzalki patrzacej na mnie
#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...