이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robot.h"
#include<bits/stdc++.h>
using namespace std;
using ll = int;
const ll blk = 4;
const ll bk = 5;
const ll rm = 6;
const vector<ll> bls = {-2,-1,4,blk};
#define For(a,l,r) for(ll a = (l);a<=(r);a++)
#define Al(a) For(a,-2,8)
#define Bl(a) for(ll a : bls)
set<vector<int>> used;
void add_instruction(vector<int> S, int Z, char A){
if(used.count(S)) return;
used.insert(S);
set_instruction(S,Z,A);
}
void program_pulibot(){
string fn = "WSEN";
For(i,1,2) Al(a) Al(b) Al(c){
vector<ll> v(5,0);
v[0] = bk;
v[i+1] = blk;
v[(i+1)%4+1] = a;
v[(i+2)%4+1] = b;
v[(i+3)%4+1] = c;
add_instruction(v,bk,fn[i]);
v[0] = blk;
add_instruction(v,rm,fn[i]);
v[0] = rm;
add_instruction(v,rm,fn[i]);
}
For(i,0,3) Al(a) Al(b) Al(c){
vector<ll> v(5,0);
v[0] = blk;
v[i+1] = rm;
v[(i+1)%4+1] = a;
v[(i+2)%4+1] = b;
v[(i+3)%4+1] = c;
add_instruction(v,0,fn[i]);
v[i+1] = bk;
add_instruction(v,0,fn[i]);
v[0] = rm;
add_instruction(v,0,fn[i]);
v[i+1] = rm;
add_instruction(v,0,fn[i]);
}
Al(a) Al(c) Al(b) add_instruction({bk,-2,bk,b,-2},1,'S');
Al(a) Al(c) Al(b) add_instruction({bk,-2,b,bk,-2},1,'E');
Al(a) Al(c) Al(b) add_instruction({c,-2,bk,b,-2},bk,'H');
Al(a) Al(c) Al(b) add_instruction({c,-2,b,bk,-2},bk,'H');
Al(a) Al(b) Al(c) add_instruction({3,3,a,bk,c},bk,'W');
Al(a) Al(b) Al(c) add_instruction({2,3,a,bk,c},bk,'W');
Al(a) Al(b) Al(c) add_instruction({3,3,bk,b,c},bk,'W');
Al(a) Al(b) Al(c) add_instruction({2,3,bk,b,c},bk,'W');
Al(a) Al(b) Al(c) add_instruction({3,c,a,bk,2},bk,'N');
Al(a) Al(b) Al(c) add_instruction({2,c,a,bk,2},bk,'N');
Al(a) Al(b) Al(c) add_instruction({3,c,bk,b,2},bk,'N');
Al(a) Al(b) Al(c) add_instruction({2,c,bk,b,2},bk,'N');
Al(a) Al(b) add_instruction({0,3,-2,-2,b},bk,'W');
Al(a) Al(b) add_instruction({0,a,-2,-2,2},bk,'N');
Al(a) Al(b) Al(c) add_instruction({0,a,0,b,c},2,'S');
Al(a) Bl(b) Al(c) add_instruction({0,a,b,0,c},3,'E');
Al(a) Bl(b) Al(c) add_instruction({2,a,b,0,c},3,'E');
Al(a) Bl(b) Al(c) add_instruction({0,3,a,b,c},4,'W');
Al(a) Bl(b) Al(c) add_instruction({2,3,a,b,c},4,'W');
Al(a) Bl(b) Al(c) add_instruction({3,3,a,b,c},4,'W');
Al(a) Bl(b) Al(c) add_instruction({2,a,b,c,2},4,'N');
Al(a) Bl(b) Al(c) add_instruction({3,a,b,c,2},4,'N');
Al(a) Bl(b) Al(c) add_instruction({0,a,b,c,2},4,'N');
For(i,0,3){
Al(a) Al(b) Al(c){
add_instruction({bk,bk,a,b,c},1,fn[0]);
add_instruction({bk,a,bk,b,c},1,fn[1]);
add_instruction({bk,a,b,bk,c},1,fn[2]);
add_instruction({bk,a,b,c,bk},1,fn[3]);
}
}
Al(a) Al(b) add_instruction({bk,a,-2,-2,b},1,'T');
/*Al(a) Al(b) add_instruction({7,a,-2,-2,b},1,'T');
For(i,0,3) Al(a) Al(b) Al(c){
vector<ll> v(5,0);
v[0] = bk;
v[i+1] = blk;
v[(i+1)%4+1] = a;
v[(i+2)%4+1] = b;
v[(i+3)%4+1] = c;
add_instruction(v,bk,fn[i]);
v[0] = blk;
add_instruction(v,rm,fn[i]);
v[0] = rm;
add_instruction(v,rm,fn[i]);
}
For(i,0,3) Al(a) Al(b) Al(c){
vector<ll> v(5,0);
v[0] = blk;
v[i+1] = rm;
v[(i+1)%4+1] = a;
v[(i+2)%4+1] = b;
v[(i+3)%4+1] = c;
add_instruction(v,0,fn[i]);
v[i+1] = bk;
add_instruction(v,0,fn[i]);
v[0] = rm;
add_instruction(v,0,fn[i]);
v[i+1] = rm;
add_instruction(v,0,fn[i]);
}
For(i,0,3){
Al(a) Al(b) Al(c){
vector<ll> v(5,0);
v[0] = c;
v[((i+2)%4)+1] = i+2;
v[((i+0)%4)+1] = bk;
v[((i+1)%4)+1] = a;
v[((i+3)%4)+1] = b;
add_instruction(v,bk,fn[((i+2)%4)]);
v[((i+0)%4)+1] = a;
v[((i+1)%4)+1] = bk;
v[((i+3)%4)+1] = b;
add_instruction(v,bk,fn[((i+2)%4)]);
v[((i+0)%4)+1] = a;
v[((i+1)%4)+1] = b;
v[((i+3)%4)+1] = bk;
add_instruction(v,bk,fn[((i+2)%4)]);
}
Al(a) Al(b) Al(c){
add_instruction({bk,bk,a,b,c},1,fn[0]);
add_instruction({bk,a,bk,b,c},1,fn[1]);
add_instruction({bk,a,b,bk,c},1,fn[2]);
add_instruction({bk,a,b,c,bk},1,fn[3]);
}
}
Al(a) add_instruction({0,a,-2,-2,3},bk,'N');
Al(a) add_instruction({0,4,-2,-2,a},bk,'W');
Al(a) Al(b) add_instruction({b,-2,a,7,-2},bk,'H');
Al(a) Al(b) add_instruction({b,-2,7,a,-2},bk,'H');
For(i,0,3){
Al(a) Al(b) Al(c){
vector<ll> v(5,0);
v[0] = c;
v[((i+2)%4)+1] = i+2;
v[((i+1)%4)+1] = a;
v[((i+0)%4)+1] = 0;
v[((i+3)%4)+1] = b;
add_instruction(v,((i+0)%4)+2,fn[((i+0)%4)]);
}
Al(a) Al(b) Al(c){
vector<ll> v(5,0);
v[0] = c;
v[((i+2)%4)+1] = i+2;
v[((i+1)%4)+1] = a;
v[((i+0)%4)+1] = b;
add_instruction(v,((i+3)%4)+2,fn[((i+3)%4)]);
}
Al(a) Al(b) Al(c){
vector<ll> v(5,0);
v[0] = c;
v[((i+2)%4)+1] = i+2;
v[((i+1)%4)+1] = 0;
v[((i+0)%4)+1] = a;
v[((i+3)%4)+1] = b;
add_instruction(v,((i+1)%4)+2,fn[((i+1)%4)]);
}
Bl(a) Bl(b) Bl(c) Al(d){
vector<ll> v(5,0);
v[0] = d;
v[((i+2)%4)+1] = i+2;
v[((i+0)%4)+1] = a;
v[((i+1)%4)+1] = b;
v[((i+3)%4)+1] = c;
add_instruction(v,blk,fn[((i+2)%4)]);
}
}
Al(a) Al(c) Al(b) add_instruction({c,-2,0,b,-2},3,'S');
Al(a) Al(c) Al(b) add_instruction({c,-2,b,0,-2},4,'E');
//cerr << used.size() << "\n";*/
}
# | 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... |