Codeforces/266/a.cpp
Matej Focko 85ccacae44
266(A,cpp): solve “Stones on the Table”
Signed-off-by: Matej Focko <me@mfocko.xyz>
2023-07-10 11:32:16 +02:00

68 lines
No EOL
882 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <iostream>
#include <string>
namespace {
using namespace std;
int remove(const std::string& s) {
int counter = 0;
for (auto i = 0; i < s.size() - 1; ++i) {
if (s[i] == s[i + 1]) {
++counter;
}
}
return counter;
}
void solve() {
int size;
cin >> size;
std::string line;
cin >> line;
cout << remove(line) << "\n";
}
} // namespace
// for single test case, comment out for N test cases
#define SINGLE
#ifndef TEST
int main(void) {
#ifdef SINGLE
solve();
#else
// for multiple test cases
int N;
std::cin >> N >> std::ws;
for (auto i = 0; i < N; ++i) {
solve();
}
#endif
return 0;
}
#else
#include "../.common/cpp/catch_amalgamated.hpp"
TEST_CASE("examples") {
CHECK(remove(std::string("RRG")) == 1);
CHECK(remove(std::string("RRRRR")) == 4);
CHECK(remove(std::string("BRBG")) == 0);
}
#endif