Submission #1027334

#TimeUsernameProblemLanguageResultExecution timeMemory
1027334LIFRobot Contest (IOI23_robot)C++17
9 / 100
88 ms5772 KiB
#include "robot.h" #include<bits/stdc++.h> using namespace std; enum state { Extent, //如果存在0時向四周擴展 Back, //如果不存在0時,代表應返回 End, //-2 -2 }; class robot { public: state robot_state; vector<int> S; robot(){return;} robot(vector<int> _S)//init; { S = _S; 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; } } 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; A = 'T'; } if(now_robot.robot_state == state::Extent) { for(int i=2;i<=6;i++) { if(i%5 == 0)continue; if(now_robot.S[i%5] == 0) { Z = 1; A = find_direction(i%5); } } } if(now_robot.robot_state == state::Back) { for(int i=1;i<5;i++) { if(now_robot.S[i] == 1) { Z = 2; A = find_direction(i); } } } 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<=2;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...