QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#192208 | #7516. Robot Experiment | ucup-team896# | WA | 275ms | 3548kb | C++14 | 1.6kb | 2023-09-30 13:56:08 | 2023-09-30 13:56:09 |
Judging History
answer
#include <bits/stdc++.h>
#ifdef dbg
#define D(...) fprintf(stderr, __VA_ARGS__)
#define DD(...) D(#__VA_ARGS__ " = "), debug_helper::debug(__VA_ARGS__), D("\n")
#include "C:\Users\wsyear\Desktop\OI\templates\debug.hpp"
#else
#define D(...) ((void)0)
#define DD(...) ((void)0)
#endif
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using namespace std;
const int N = 21;
int n;
char s[N];
map<pii, int> mp, ans;
int main() {
cin.tie(nullptr) -> ios::sync_with_stdio(false);
cin >> n >> (s + 1);
rep (mask, 0, (1 << n) - 1) {
mp.clear();
int x = 0, y = 0, ok = 1;
rep (i, 0, n - 1) {
int tx = x, ty = y;
if (s[i + 1] == 'L') tx--;
if (s[i + 1] == 'R') tx++;
if (s[i + 1] == 'D') ty--;
if (s[i + 1] == 'U') ty++;
if (mask >> i & 1) {
x = tx, y = ty;
} else {
mp[pii(tx, ty)] = 1;
}
}
x = 0, y = 0;
if (mp.count(pii(0, 0))) continue;
rep (i, 0, n - 1) {
int tx = x, ty = y;
if (s[i + 1] == 'L') tx--;
if (s[i + 1] == 'R') tx++;
if (s[i + 1] == 'D') ty--;
if (s[i + 1] == 'U') ty++;
if (mask >> i & 1) {
if (mp.count(pii(tx, ty))) ok = 0;
x = tx, y = ty;
}
}
if (ok) ans[pii(x, y)] = 1;
}
cout << SZ(ans) << "\n";
for (auto [x, y] : ans) cout << x.fi << " " << x.se << "\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3368kb
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: 3488kb
input:
4 LRUD
output:
4 0 -1 0 0 1 -1 1 0
result:
ok 5 lines
Test #3:
score: -100
Wrong Answer
time: 275ms
memory: 3548kb
input:
20 LLLRLRLRLLLRLLRLRLLR
output:
8 -7 0 -6 0 -5 0 -4 0 -3 0 -2 0 -1 0 0 0
result:
wrong answer 2nd lines differ - expected: '-6 0', found: '-7 0'