Task: | Forgotten measurements |
Sender: | ¯\_(._.)_/¯ |
Submission time: | 2024-11-16 14:10:04 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.03 s | details |
#7 | ACCEPTED | 0.03 s | details |
#8 | ACCEPTED | 0.03 s | details |
#9 | ACCEPTED | 0.03 s | details |
#10 | ACCEPTED | 0.03 s | details |
#11 | ACCEPTED | 0.03 s | details |
Compiler report
input/code.cpp: In function 'void solve()': input/code.cpp:17:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 17 | for (int i = 0; i < s.size(); i++) | ~~^~~~~~~~~~
Code
#include <bits/stdc++.h> #include <iostream> #define int long long using namespace std; void solve() { string s; cin >> s; int u = 0; int d = 0; int l = 0; int r = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == 'U') u++; if (s[i] == 'L') l++; if (s[i] == 'D') d++; if (s[i] == 'R') r++; } cout << min(u, d) + min(l, r); } signed main() { int t = 1; // cin >> t; for (int i = 0; i < t; i++) solve(); }
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 |