QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#240817 | #7516. Robot Experiment | dayux | WA | 0ms | 3540kb | C++14 | 1.2kb | 2023-11-05 19:47:25 | 2023-11-05 19:47:25 |
Judging History
answer
#include <bits/stdc++.h>
const int maxn = 20;
int n;
std::vector<std::pair<int, int>> vres;
std::array<char, maxn + 2> str;
std::array<std::array<int, maxn * 2 + 1>, maxn * 2 + 1> type;
void dfs(int d, int x, int y) {
if (d == n + 1) {
vres.emplace_back(x, y);
return;
}
int nx = x, ny = y;
switch (str[d]) {
case 'L':
--nx;
break;
case 'R':
++nx;
break;
case 'D':
--ny;
break;
case 'U':
++ny;
break;
}
if (type[nx][ny] != 2) {
int o = type[nx][ny];
type[nx][ny] = 1;
dfs(d + 1, x, y);
type[nx][ny] = o;
}
if (type[nx][ny] != 1) {
int o = type[nx][ny];
type[nx][ny] = 2;
dfs(d + 1, nx, ny);
type[nx][ny] = o;
}
}
int main() {
#ifndef ONLINE_JUDGE
std::freopen("E.in", "r", stdin);
std::freopen("E.out", "w", stdout);
#endif
std::cin >> n >> std::next(str.data());
type[maxn][maxn] = 2;
dfs(1, maxn, maxn);
std::sort(vres.begin(), vres.end());
vres.erase(std::unique(vres.begin(), vres.end()), vres.end());
for (const std::pair<int, int> &pr : vres)
std::cout << pr.first - maxn << ' ' << pr.second - maxn << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3540kb
input:
2 RU
output:
0 0 0 1 1 0 1 1
result:
wrong answer 1st lines differ - expected: '4', found: '0 0'