Task: | Forgotten measurements |
Sender: | Barren plateau |
Submission time: | 2024-11-16 13:22:08 +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.04 s | details |
#7 | WRONG ANSWER | 0.04 s | details |
#8 | WRONG ANSWER | 0.04 s | details |
#9 | WRONG ANSWER | 0.04 s | details |
#10 | WRONG ANSWER | 0.04 s | details |
#11 | WRONG ANSWER | 0.04 s | details |
Code
#include <bits/stdc++.h> using namespace std; int main() { string s; cin>>s; int horSum=0; int parsa=0; char cur='A'; int len = 0; for (int i = 0; i < (int)s.size();i++) { if (s[i]==cur) { len++; } else if (s[i]=='U' || s[i]=='D') continue; else { parsa = max(parsa,len); horSum += len; len = 1; cur = s[i]; } } horSum+=len; parsa = max(parsa, len); cur='A'; len = 0; for (int i=0; i<(int)s.size();i++) { if (s[i]=='U' || s[i]=='D') continue; if (s[i]!=cur && cur!='A') break; cur=s[i]; len++; } for (int i=(int)s.size()-1;i>0;i--) { if (s[i]=='U' || s[i]=='D') continue; if (s[i]!=cur) break; len++; } parsa = max(parsa,len); horSum -= parsa; int verSum = 0; parsa = 0; cur = 'A'; len = 0; for (int i = 0; i < (int)s.size();i++) { if (s[i]==cur) { len++; } else if (s[i]=='L' || s[i]=='R') continue; else { parsa = max(parsa,len); verSum += len; len = 1; cur=s[i]; } } verSum += len; parsa = max(parsa,len); for (int i=0; i<(int)s.size();i++) { if (s[i]=='L' || s[i]=='R') continue; if (s[i]!=cur) break; len++; } parsa = max(parsa,len); verSum -= parsa; cout << horSum + verSum << "\n"; }
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 |