CSES - HIIT Open 2024 - Results
Submission details
Task:Forgotten measurements
Sender:¯\_(._.)_/¯
Submission time:2024-11-16 13:46:34 +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
#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 'void solve()':
input/code.cpp:13: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]
   13 |     for (int i = 1; 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 size = s.size();
    for (int i = 1; i < s.size(); i++)
        if (s[i-1] == s[i])
            size--;
    if (s[0] == s.back())
        size--;

    int c = size / 3;
    if (size % 3 != 0)
        c++;

    cout << c;
}

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:

input
RULDRURDRURDLULD

correct output
7

user output
6

Test 4

Verdict:

input
LDLDRDLULULURURURULDRDLDRDRURD...

correct output
19

user output
14

Test 5

Verdict:

input
RURULDLULDRURDLULDRULURULURDLD...

correct output
470

user output
332

Test 6

Verdict:

input
DRULDLULDLULDLURDRULDRURDLURDL...

correct output
499773

user output
333328

Test 7

Verdict:

input
DLURDLULDLULDRULURULURURDLDLDR...

correct output
499383

user output
333328

Test 8

Verdict:

input
RULDLDLDRULDLDLULURULULDLURDLU...

correct output
499622

user output
333330

Test 9

Verdict:

input
RDRDRURDLDLURDRULURDLDRULDLULU...

correct output
499788

user output
333332

Test 10

Verdict:

input
LDLURDRURDRULDLULDLDRURDLULDRU...

correct output
499368

user output
333330

Test 11

Verdict:

input
DRULULDRDLDLDLURULDRDLURULULDR...

correct output
499790

user output
333330