This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
return;
}
}
}
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()的形式
{
/*if(now_robot.S[0] == 1 && now_robot.S[1] == 0 && now_robot.S[2] == 0 && now_robot.S[3] == -2 && now_robot.S[4] == 1)
{
cout<<Z<<" "<<A<<endl;
}*/
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |