제출 #1027211

#제출 시각아이디문제언어결과실행 시간메모리
1027211LIF로봇 대회 (IOI23_robot)C++17
0 / 100
1 ms348 KiB
#include "robot.h" #include<bits/stdc++.h> using namespace std; enum state { Start, //當在起點,且已經存在1,代表已經回到起點 Extent, //如果存在0時向四周擴展 Back, //如果不存在0時,代表應返回 End, //-2 -2 Clear, //無路可走時,正式clear,返回到1和4; Clear_extent, //當周圍存在4時,去找2 }; class robot { public: state robot_state; vector<int> S; robot(){return;} robot(vector<int> _S)//init; { S = _S; if((S[1] == -2 && S[4] == -2) && (S[2] == 1 || S[3] == 1)) { robot_state = state::Start; return; } if(S[2] == -2 && S[3] == -2) { robot_state = state::End; return; } for(int it = 1;it<5;it++) { if(S[it] == 0) { robot_state = state::Extent; return; } } for(int i=0;i<5;i++) { if(S[i] == 1 || S[i] == 4) // 周圍存在4; { for(int j=1;j<5;j++) { if(S[j] == 2) { robot_state = state::Clear_extent; return; } } for(int j=1;j<5;j++) { if(S[j] == 0) { robot_state = state::Clear; } } } } robot_state = state::Back; } }; class instruction { public: robot now_robot; int Z; char A; char find_direction(int num) { if(num == 1)return 'W'; if(num == 2)return 'S'; if(num == 3)return 'E'; if(num == 4)return 'N'; return '0'; } instruction(robot _now) { now_robot = _now; if(now_robot.robot_state == state::End) { Z = 1; for(int i=1;i<5;i++) { if(now_robot.S[i] == 1)A = find_direction(i); } } if(now_robot.robot_state == state::Extent) { for(int i=1;i<5;i++) { if(now_robot.S[i] == 0) { Z = 3; A = find_direction(i); } } } if(now_robot.robot_state == state::Back) { for(int i=1;i<5;i++) { if(now_robot.S[i] == 3) { Z = 2; A = find_direction(i); } } } if(now_robot.robot_state == state::Clear) { //沿著1或4的方向去走; for(int i=1;i<5;i++) { if(now_robot.S[i] == 1 || now_robot.S[i] == 4) { Z = 0; A = find_direction(i); } } } if(now_robot.robot_state == state::Clear_extent) { for(int i=1;i<5;i++) { if(now_robot.S[i] == 2) { Z = 4; A = find_direction(i); } } } if(now_robot.robot_state == state::Start) { Z = 1; A = 'T'; } return; } void work() //除構造函數外,應寫成 void function() / int function()的形式 { set_instruction(now_robot.S,Z,A); return; } }; void program_pulibot() { vector<int> v; for(int i=-2;i<=4;i++)v.push_back(i); for(auto it : v)//可以縮進取代多個大括號 for(auto it2 : v) for(auto it3 : v) for(auto it4 : v) for(auto it5 : v) { vector<int> temp; temp = {it,it2,it3,it4,it5}; robot now_robot(temp); instruction now_instruction(now_robot); now_instruction.work(); } //注 s[0]原地,s[1] 西方,s[2]南方,s[3]東方,s[4]北方 }
#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...