CSES - HIIT Open 2024 - Results
Submission details
Task:Forgotten measurements
Sender:CPLX
Submission time:2024-11-16 15:43:14 +0200
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.03 sdetails
#70.03 sdetails
#80.03 sdetails
#90.03 sdetails
#100.03 sdetails
#110.03 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:22:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(ll i=0; i<s.size(); i +=2){
      |                 ~^~~~~~~~~

Code

#include <iostream>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;
typedef long long ll;

#define UPLEFT 0
#define UPRIGHT 1
#define DOWNLEFT 2
#define DOWNRIGHT 3


int main(){
    string s;
    cin >> s;

    vector<ll> count(4,0);


    for(ll i=0; i<s.size(); i +=2){
        if(s[i]=='U' and s[i+1]=='L')count[UPLEFT] +=1;
        else if(s[i]=='L' and s[i+1]=='U')count[UPLEFT] +=1;

        else if(s[i]=='U' and s[i+1]=='R')count[UPRIGHT] +=1;
        else if(s[i]=='R' and s[i+1]=='U')count[UPRIGHT] +=1;

        else if(s[i]=='D' and s[i+1]=='L')count[DOWNLEFT] +=1;
        else if(s[i]=='L' and s[i+1]=='D')count[DOWNLEFT] +=1;

        else if(s[i]=='D' and s[i+1]=='R')count[DOWNRIGHT] +=1;
        else if(s[i]=='R' and s[i+1]=='D')count[DOWNRIGHT] +=1;

    }



    cout << max(count[UPLEFT], count[DOWNRIGHT]) + max(count[UPRIGHT], count[DOWNLEFT])  << endl;
}

Test details

Test 1

Verdict: ACCEPTED

input
ULDRUR

correct output
2

user output
2

Test 2

Verdict:

input
RULD

correct output
2

user output
1

Test 3

Verdict:

input
RULDRURDRURDLULD

correct output
7

user output
5

Test 4

Verdict:

input
LDLDRDLULULURURURULDRDLDRDRURD...

correct output
19

user output
11

Test 5

Verdict:

input
RURULDLULDRURDLULDRULURULURDLD...

correct output
470

user output
266

Test 6

Verdict:

input
DRULDLULDLULDLURDRULDRURDLURDL...

correct output
499773

user output
250123

Test 7

Verdict:

input
DLURDLULDLULDRULURULURURDLDLDR...

correct output
499383

user output
250492

Test 8

Verdict:

input
RULDLDLDRULDLDLULURULULDLURDLU...

correct output
499622

user output
250197

Test 9

Verdict:

input
RDRDRURDLDLURDRULURDLDRULDLULU...

correct output
499788

user output
250194

Test 10

Verdict:

input
LDLURDRURDRULDLULDLDRURDLULDRU...

correct output
499368

user output
250348

Test 11

Verdict:

input
DRULULDRDLDLDLURULDRDLURULULDR...

correct output
499790

user output
250138