이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robot.h"
#include <iostream>
using namespace std;
enum Block_state
{
Start,
Extent,
Back,
End,
Clean,
Clean_extent,
};
class Block
{
public:
std::vector<int> S;
Block_state state;
Block() {}
Block(std::vector<int> _S)
{
S = _S;
if (S[2] == -2 && S[3] == -2)
{
state = Block_state::End;
return;
}
for (int i = 0; i < 5; i++)
{
if (S[i] == 1 || S[i] == 4)
{
int flag = 0;
for (int j = 1; j < 5; j++)
{
if (S[j] == 2)
{
state = Block_state::Clean_extent;
return;
}
}
if (S[1] == -2 && S[4] == -2 && (S[2] == 1 || S[3] == 1))
{
state = Block_state::Start;
return;
}
state = Block_state::Clean;
return;
}
}
for (int i = 1; i < 5; i++)
{
if (S[i] == 0)
{
state = Block_state::Extent;
return;
}
}
state = Block_state::Back;
}
};
class Instruction
{
public:
Block block;
int Z;
char A = '0';
char step(int pos)
{
if (pos == 1)
return 'W';
if (pos == 2)
return 'S';
if (pos == 3)
return 'E';
if (pos == 4)
return 'N';
}
char step_col(int col)
{
for (int i = 1; i < 5; i++)
{
if (block.S[i] == col)
return step(i);
}
return '0';
}
Instruction(Block _block)
{
block = _block;
if (block.state == Extent)
{
for (int i = 1; i < 5; i++)
{
if (block.S[i] == 0)
{
Z = 3;
A = step(i);
return;
}
}
}
if (block.state == Block_state::Back)
{
for (int i = 1; i < 5; i++)
{
if (block.S[i] == 3)
{
Z = 2;
A = step(i);
return;
}
}
}
if (block.state == Block_state::End)
{
Z = 1;
for (int i = 1; i < 5; i++)
{
if (block.S[i] == 3)
A = step(i);
}
return;
}
if (block.state == Block_state::Clean_extent)
{
Z = 4;
A = step_col(2);
}
if (block.state == Block_state::Clean)
{
A = step_col(4);
if (A == '0')
{
Z = 1;
A = step_col(3);
}
else
Z = 0;
}
if (block.state == Block_state::Start)
{
A = 'T';
Z = 1;
}
}
void program()
{
if (A == '0')
return;
set_instruction(block.S, Z, A);
}
};
class Student
{
public:
int age, id;
Student(int _age)
{
age = _age;
id = 0;
}
};
void program_pulibot()
{
for (int a0 = -2; a0 <= 4; a0++)
for (int a1 = -2; a1 <= 4; a1++)
for (int a2 = -2; a2 <= 4; a2++)
for (int a3 = -2; a3 <= 4; a3++)
for (int a4 = -2; a4 <= 4; a4++)
{
vector<int> S = {a0, a1, a2, a3, a4};
Block block(S);
Instruction instruction(block);
instruction.program();
}
}
컴파일 시 표준 에러 (stderr) 메시지
robot.cpp: In constructor 'Block::Block(std::vector<int>)':
robot.cpp:36:21: warning: unused variable 'flag' [-Wunused-variable]
36 | int flag = 0;
| ^~~~
robot.cpp: In member function 'char Instruction::step(int)':
robot.cpp:85:5: warning: control reaches end of non-void function [-Wreturn-type]
85 | }
| ^
# | 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... |