QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#242431 | #7516. Robot Experiment | yyz | WA | 226ms | 3596kb | C++14 | 1.7kb | 2023-11-07 13:35:28 | 2023-11-07 13:35:29 |
Judging History
answer
#include <bits/stdc++.h>
#define V vector
#define Vi vector<int>
#define sz(a) ((int)a.size())
#define fi first
#define se second
#define Int pair<int, int>
#define Inf ((int)1e9)
#define pb push_back
#define ins insert
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define seg int p, int l, int r
#define lid p << 1, l, mid
#define all(a) a.begin(), a.end()
#define rid p << 1 | 1, mid + 1, r
#define mid ((l + r) / 2)
#define Ceil(x, y) ((x + y - 1) / y)
#define IO(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout);
using namespace std;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, 1, -1};
int main() {
#ifndef ONLINE_JUDGE
IO(1);
#endif
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n;
cin >> n;
string st;
cin >> st;
Vi a(n);
For(i, 0, n - 1) {
if (st[i] == 'L') a[i] = 0;
if (st[i] == 'R') a[i] = 1;
if (st[i] == 'U') a[i] = 2;
if (st[i] == 'D') a[i] = 3;
}
V<Int> res;
V<Vi> vis(2 * n + 5, Vi(2 * n + 5));
For(i, 0, (1 << n) - 1) {
int x = n, y = n, ff = 0;
vis[x][y] = -1;
V<Int> vec;
For(j, 0, n - 1) {
int xx = x + dx[a[j]], yy = y + dy[a[j]];
if ((i >> j) & 1) {
if (vis[xx][yy]) ff = 1;
x = xx, y = yy;
vis[x][y] = -1;
vec.pb({x, y});
} else {
if (vis[xx][yy] == -1) ff = 1;
vis[xx][yy] = 1;
vec.pb({xx, yy});
}
}
for (auto i : vec) vis[i.fi][i.se] = 0;
if (!ff) res.pb({x - n, y - n});
}
sort(all(res));
res.erase(unique(all(res)), res.end());
cout << sz(res) << '\n';
for (auto i : res) cout << i.fi << ' ' << i.se << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
input:
2 RU
output:
4 0 0 0 1 1 0 1 1
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
4 LRUD
output:
4 0 -1 0 0 1 -1 1 0
result:
ok 5 lines
Test #3:
score: -100
Wrong Answer
time: 226ms
memory: 3596kb
input:
20 LLLRLRLRLLLRLLRLRLLR
output:
1 0 0
result:
wrong answer 1st lines differ - expected: '8', found: '1'