이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h>
#include "robot.h"
using namespace std;
#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define RREP(i, s, e) for (int i = (s); i >= (e); i--)
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;
#ifndef DEBUG
#define cerr if (0) cerr
#endif
const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 20;
const int Z = 5;
const char key[] = "HTWSEN";
inline int opp(int d) {
return d ^ 6;
}
inline int nxt(int d) {
return (++d > Z ? d - 4 : d);
}
void solve(vi S) {
vi s = S;
s.insert(s.begin() + 1, 0);
bool tlcorner = s[2] == -2 && s[5] == -2,
brcorner = s[3] == -2 && s[4] == -2;
int d = s[0];
if (d == 0) {
if (brcorner) {
set_instruction(S, 4, key[0]);
return;
}
int nd = -1;
REP (k, 2, 6) {
if (opp(s[k]) == k) {
set_instruction(S, k, key[k]);
return;
}
if (s[k] == 0 && nd == -1) {
nd = k;
}
}
if (tlcorner && nd != -1) {
set_instruction(S, nd, key[nd]);
}
return;
} else if (opp(s[d]) == d) {
while (d = nxt(d)) {
if (opp(s[d]) == d || s[d] == 0) {
set_instruction(S, d, key[d]);
return;
}
}
} else {
int cnt1 = 0;
REP (k, 2, 6) {
if (opp(s[k]) == k) {
set_instruction(S, d, key[k]);
return;
}
cnt1 += s[k] == 1;
}
set_instruction(S, tlcorner || cnt1, key[brcorner ? 1 : d]);
}
}
void program_pulibot() {
REP (_m, 0, Z + 1) {
REP (_w, -2, Z + 1) {
REP (_s, -2, Z + 1) {
REP (_e, -2, Z + 1) {
REP (_n, -2, Z + 1) {
solve({_m, _w, _s, _e, _n});
}
}
}
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
robot.cpp: In function 'void solve(vi)':
robot.cpp:76:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
76 | while (d = nxt(d)) {
| ~~^~~~~~~~
# | 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... |