CSES - HIIT Open 2024 - Results
Submission details
Task:Forgotten measurements
Sender:CPLX
Submission time:2024-11-16 15:56:29 +0200
Language:C++ (C++17)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.03 sdetails
#7ACCEPTED0.03 sdetails
#8ACCEPTED0.03 sdetails
#9ACCEPTED0.03 sdetails
#10ACCEPTED0.04 sdetails
#11ACCEPTED0.03 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:16: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]
   16 |     for(ll i=0; i<s.size(); i++){
      |                 ~^~~~~~~~~

Code

#include <iostream>
#include <string>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
int main(){
    ll idx1=0;
    ll idx2=0;
    ll idx3=0;
    ll idx4=0;
 
    string s;
    cin >> s;
 
    for(ll i=0; i<s.size(); i++){
        if(s[i]=='U') idx1 +=1;
        else if(s[i]=='D') idx2 +=1;
        else if(s[i]=='L') idx3 +=1;
        else if(s[i]=='R') idx4 +=1;
    }
 
    cout << min(idx1,idx2) + min(idx3,idx4) << 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: ACCEPTED

input
RULDRURDRURDLULD

correct output
7

user output
7

Test 4

Verdict: ACCEPTED

input
LDLDRDLULULURURURULDRDLDRDRURD...

correct output
19

user output
19

Test 5

Verdict: ACCEPTED

input
RURULDLULDRURDLULDRULURULURDLD...

correct output
470

user output
470

Test 6

Verdict: ACCEPTED

input
DRULDLULDLULDLURDRULDRURDLURDL...

correct output
499773

user output
499773

Test 7

Verdict: ACCEPTED

input
DLURDLULDLULDRULURULURURDLDLDR...

correct output
499383

user output
499383

Test 8

Verdict: ACCEPTED

input
RULDLDLDRULDLDLULURULULDLURDLU...

correct output
499622

user output
499622

Test 9

Verdict: ACCEPTED

input
RDRDRURDLDLURDRULURDLDRULDLULU...

correct output
499788

user output
499788

Test 10

Verdict: ACCEPTED

input
LDLURDRURDRULDLULDLDRURDLULDRU...

correct output
499368

user output
499368

Test 11

Verdict: ACCEPTED

input
DRULULDRDLDLDLURULDRDLURULULDR...

correct output
499790

user output
499790