CSES - Datatähti 2022 loppu - Results
Submission details
Task:Peli
Sender:cowperso
Submission time:2022-01-22 16:31:55 +0200
Language:C++ (C++11)
Status:READY
Result:11
Feedback
groupverdictscore
#1ACCEPTED11
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#20.01 s2, 3details
#30.01 s3details
#4ACCEPTED0.01 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details

Code

#include <iostream>

bool have[3];

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  uint32_t n, k;
  std::cin >> n >> k;
  std::string kirj;
  std::cin >> kirj;

  if (k < 3) {
    std::cout << "0\n";
    return 0;
  }
  uint32_t res = 0;
  if (k == 3) {
    for (auto c : kirj) {
      if (have[c - 'A'])
        continue;
      have[c - 'A'] = true;
      if (have[0] && have[1] && have[2]) {
        ++res;
        have[0] = have[1] = have[2] = false;
      }
    }
    std::cout << res << '\n';
    return 0;
  } else {
    return 1;
  }
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
100000 3
BBAACBCBACBACABBCBAABCBCCBCCAA...

correct output
18201

user output
18201

Test 2

Group: 2, 3

Verdict:

input
100000 10
BAACABCCBCBAACBBCCCCABBBBACCBA...

correct output
29684

user output
(empty)

Test 3

Group: 3

Verdict:

input
100000 50
ACAABCBBAAAACCBBABACACACBCAACA...

correct output
32740

user output
(empty)

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

input
3 1
ABC

correct output
0

user output
0

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

input
3 2
ABC

correct output
0

user output
0