CSES - HIIT Open 2024 - Results
Submission details
Task:Forgotten measurements
Sender:undefined reference to 'Päivölä'
Submission time:2024-11-16 14:55:09 +0200
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#6--details
#7--details
#8--details
#9--details
#10--details
#11--details

Code

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef uint64_t u64;

int main()
{
    string input;
    cin >> input;
    u64 out = 1;
    u64 i = 0;
    while (i < input.size())
    {
        if (input[i] == 'U' && input[i + 2] == 'D')
        {
            out++;
            input.erase(i, 4);
            i = i<2 ? 0 : i-2;
        }
        if (input[i] == 'D' && input[i + 2] == 'U')
        {
            out++;
            input.erase(i, 4);
            i = i<2 ? 0 : i-2;
        }
        if (input[i] == 'L' && input[i + 2] == 'R')
        {
            out++;
            input.erase(i, 4);
            i = i<2 ? 0 : i-2;
        }
        if (input[i] == 'R' && input[i + 2] == 'L')
        {
            out++;
            input.erase(i, 4);
            i = i<2 ? 0 : i-2;
        }
        i++;
    }
    cout << out;
}

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:

input
RULDRURDRURDLULD

correct output
7

user output
5

Test 4

Verdict:

input
LDLDRDLULULURURURULDRDLDRDRURD...

correct output
19

user output
10

Test 5

Verdict:

input
RURULDLULDRURDLULDRULURULURDLD...

correct output
470

user output
250

Test 6

Verdict:

input
DRULDLULDLULDLURDRULDRURDLURDL...

correct output
499773

user output
(empty)

Test 7

Verdict:

input
DLURDLULDLULDRULURULURURDLDLDR...

correct output
499383

user output
(empty)

Test 8

Verdict:

input
RULDLDLDRULDLDLULURULULDLURDLU...

correct output
499622

user output
(empty)

Test 9

Verdict:

input
RDRDRURDLDLURDRULURDLDRULDLULU...

correct output
499788

user output
(empty)

Test 10

Verdict:

input
LDLURDRURDRULDLULDLDRURDLULDRU...

correct output
499368

user output
(empty)

Test 11

Verdict:

input
DRULULDRDLDLDLURULDRDLURULULDR...

correct output
499790

user output
(empty)