Task: | Forgotten measurements |
Sender: | Aalto CS-A1140 Team 2 |
Submission time: | 2024-11-16 14:50:11 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | WRONG ANSWER | 0.00 s | details |
#4 | WRONG ANSWER | 0.00 s | details |
#5 | WRONG ANSWER | 0.00 s | details |
#6 | WRONG ANSWER | 0.03 s | details |
#7 | WRONG ANSWER | 0.03 s | details |
#8 | WRONG ANSWER | 0.03 s | details |
#9 | WRONG ANSWER | 0.03 s | details |
#10 | WRONG ANSWER | 0.03 s | details |
#11 | WRONG ANSWER | 0.03 s | details |
Code
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a); i < (b); i++) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); string s; cin >> s; vector<int> ys, xs; for (char c : s) { if (c == 'U' || c == 'D') ys.push_back(c == 'U'); if (c == 'L' || c == 'R') xs.push_back(c == 'L'); } auto solve = [&](vector<int> x) { int n = (int)x.size(); { vi y = x; int i = 0; while (x[i] == x[(i + 1) % n]) i = (i + 1) % n; i = (i + 1) % n; for (int j = 0; j < n; ++j) { y[j] = x[(j + i) % n]; } x = y; } int mx = 0; for (int i = 0, j = 0; i < n; i = j) { while (j < n && x[i] == x[j]) ++j; mx = max(mx, j - i); } return n - mx; }; cout << solve(xs) + solve(ys) << endl; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
ULDRUR |
correct output |
---|
2 |
user output |
---|
2 |
Test 2
Verdict: ACCEPTED
input |
---|
RULD |
correct output |
---|
2 |
user output |
---|
2 |
Test 3
Verdict: WRONG ANSWER
input |
---|
RULDRURDRURDLULD |
correct output |
---|
7 |
user output |
---|
11 |
Test 4
Verdict: WRONG ANSWER
input |
---|
LDLDRDLULULURURURULDRDLDRDRURD... |
correct output |
---|
19 |
user output |
---|
31 |
Test 5
Verdict: WRONG ANSWER
input |
---|
RURULDLULDRURDLULDRULURULURDLD... |
correct output |
---|
470 |
user output |
---|
980 |
Test 6
Verdict: WRONG ANSWER
input |
---|
DRULDLULDLULDLURDRULDRURDLURDL... |
correct output |
---|
499773 |
user output |
---|
999955 |
Test 7
Verdict: WRONG ANSWER
input |
---|
DLURDLULDLULDRULURULURURDLDLDR... |
correct output |
---|
499383 |
user output |
---|
999954 |
Test 8
Verdict: WRONG ANSWER
input |
---|
RULDLDLDRULDLDLULURULULDLURDLU... |
correct output |
---|
499622 |
user output |
---|
999961 |
Test 9
Verdict: WRONG ANSWER
input |
---|
RDRDRURDLDLURDRULURDLDRULDLULU... |
correct output |
---|
499788 |
user output |
---|
999967 |
Test 10
Verdict: WRONG ANSWER
input |
---|
LDLURDRURDRULDLULDLDRURDLULDRU... |
correct output |
---|
499368 |
user output |
---|
999962 |
Test 11
Verdict: WRONG ANSWER
input |
---|
DRULULDRDLDLDLURULDRDLURULULDR... |
correct output |
---|
499790 |
user output |
---|
999954 |