Submission #3045870


Source Code Expand

#include <algorithm>
#include <array>
#include <bitset>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#include <cassert>
using namespace std;

struct TSolver
{
    int N;
    vector<int> Colors;

    bool Setup()
    {
        if (!(cin >> N)) {
            return false;
        }
        Colors.resize(N);
        for (int i = 0; i < N; ++i) {
            cin >> Colors[i];
        }
        return true;
    }

    void Solve()
    {
        int result = 0;
        for (int l = 0; l < N; ) {
            int r = l;
            while (Colors[r] == Colors[l] && r < N) {
                ++r;
            }
            result += (r - l) / 2;
            l = r;
        }
        cout << result << endl;
    }

    void TearDown()
    {
        cout.flush();
    }
};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    TSolver solver;
    while (solver.Setup()) {
        solver.Solve();
        solver.TearDown();
    }

    return 0;
}

Submission Info

Submission Time
Task A - Colorful Slimes 2
User bidzilya
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1258 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 4
AC × 13
Set Name Test Cases
Sample example_0, example_1, example_2, example_3
All example_0, example_1, example_2, example_3, handmade_0, handmade_1, rand_0, rand_1, smallcolor_0, smallcolor_1, smallcolor_2, smallcolor_3, smallcolor_4
Case Name Status Exec Time Memory
example_0 AC 1 ms 256 KB
example_1 AC 1 ms 256 KB
example_2 AC 1 ms 256 KB
example_3 AC 1 ms 256 KB
handmade_0 AC 1 ms 256 KB
handmade_1 AC 1 ms 256 KB
rand_0 AC 1 ms 256 KB
rand_1 AC 1 ms 256 KB
smallcolor_0 AC 1 ms 256 KB
smallcolor_1 AC 1 ms 256 KB
smallcolor_2 AC 1 ms 256 KB
smallcolor_3 AC 1 ms 256 KB
smallcolor_4 AC 1 ms 256 KB