Submission details
Task:Tulkki
Sender:lukarantalainen
Submission time:2026-06-05 21:56:56 +0300
Language:C++ (C++20)
Status:READY
Result:0
Feedback
subtaskverdictscore
#10
#20
#30
Test results
testverdicttimesubtask
#1ACCEPTED0.00 s1, 2, 3details
#20.00 s1, 2, 3details
#3ACCEPTED0.00 s1, 2, 3details
#4ACCEPTED0.00 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details
#6ACCEPTED0.01 s1, 2, 3details
#7ACCEPTED0.00 s2, 3details
#8ACCEPTED0.00 s2, 3details
#9ACCEPTED0.00 s2, 3details
#10ACCEPTED0.00 s2, 3details
#11ACCEPTED0.00 s2, 3details
#12ACCEPTED0.00 s2, 3details
#130.00 s3details
#140.00 s3details
#150.00 s3details
#160.00 s3details
#170.00 s3details
#180.00 s3details

Compiler report

input/code.cpp: In function 'void repeat(char)':
input/code.cpp:50:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for (int i{}; i<line.length(); ++i) {
      |                   ~^~~~~~~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:95:41: warning: catching polymorphic type 'const class std::bad_function_call' by value [-Wcatch-value=]
   95 |     catch (const std::bad_function_call e) {
      |                                         ^

Code

#include <iostream>
#include <map>
#include <string>
#include <sstream>
#include <functional>
#include <limits>
#include <vector>

std::map<char, int> vars;

void clear(char n);
void increase(char n);
void print(char n);
void repeat(char n);

void call(char op, char c) {
  switch(op) {
    case 'C':
    clear(c);
    break;
    case 'I':
    increase(c);
    break;
    case 'P':
    print(c);
    break;
    case 'R':
    repeat(c);
    break;
  }
}

void clear(char c) {  
  vars[c] = 0;
}

void increase(char c){
  (vars.count(c) ? ++vars[c] : vars[c] = 1);
}

void print(char c){
  std::cout << vars[c] << " ";
}

void repeat(char c){
  std::vector<std::string> commands;
  std::string line;

  while (std::getline(std::cin, line)) {
    for (int i{}; i<line.length(); ++i) {
      if (line[i] != ' ') {
        line = line.substr(i);
        break;
      }
    }
    if (line[0] == ')') break;
    if (line == "") continue;
    if (line[0] == '#') continue;
    commands.push_back(line);
  }

  int limit {vars[c]};
  for (int i{}; i<limit; ++i) {
    for (auto s : commands) {
      std::istringstream ss(s);
      
      char n;
      ss.ignore(std::numeric_limits<std::streamsize>::max(), ' ');
      ss >> n;
      call(s[0], n);
    }
  }
}

int main(){
  for (int i{}; i<26; ++i) {
    vars["ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i]] = 0;
  }

  std::string line;

  while (std::getline(std::cin, line)) {
    if (std::cin.eof()) break;
    if (line == "") continue;
    char c{line[0]};
    if (c == '#') continue;
   
    char n;
    std::stringstream ss(line);
    ss.ignore(std::numeric_limits<std::streamsize>::max(), ' ');
    ss >> n;
    try {
      call(c, n);
    }
    catch (const std::bad_function_call e) {
      std::cout << e.what() << '\n';
      std::cout << "line: " << line << '\n';
      std::cout << "n " << n << '\n';
      std::cout << "c " << c << '\n';
    }
  }

  return 0;
}

Test details

Test 1 (public)

Subtask: 1, 2, 3

Verdict: ACCEPTED

input
PRINT X
INCREASE X
PRINT X
INCREASE X
PRINT X
...

correct output
0 1 2 0 

user output
0 1 2 0 

Test 2 (public)

Subtask: 1, 2, 3

Verdict:

input
INCREASE
X
# aybabtu
   PRINT    X
INCREASE # test
...

correct output
1 3 

user output
(empty)

Feedback: Output is shorter than expected

Test 3 (public)

Subtask: 1, 2, 3

Verdict: ACCEPTED

input
# Create number 3
INCREASE X
INCREASE X
INCREASE X

...

correct output

user output

Test 4 (public)

Subtask: 1, 2, 3

Verdict: ACCEPTED

input
INCREASE A
PRINT A
INCREASE B
PRINT B
INCREASE C
...

correct output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

user output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Test 5 (public)

Subtask: 1, 2, 3

Verdict: ACCEPTED

input
INCREASE X
INCREASE X
INCREASE X
INCREASE X
INCREASE X
...

correct output
999 

user output
999 

Test 6 (public)

Subtask: 1, 2, 3

Verdict: ACCEPTED

input
PRINT X
PRINT X
PRINT X
PRINT X
PRINT X
...

correct output
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

user output
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

Test 7 (public)

Subtask: 2, 3

Verdict: ACCEPTED

input
INCREASE A
INCREASE A
INCREASE A
INCREASE A
INCREASE A
...

correct output
5 5 5 5 5 

user output
5 5 5 5 5 

Test 8 (public)

Subtask: 2, 3

Verdict: ACCEPTED

input
INCREASE A
INCREASE A
INCREASE A
INCREASE A
INCREASE A
...

correct output
0 0 0 0 0 

user output
0 0 0 0 0 

Test 9 (public)

Subtask: 2, 3

Verdict: ACCEPTED

input
INCREASE A
INCREASE A
INCREASE A
INCREASE A
INCREASE A
...

correct output
6 7 8 9 10 

user output
6 7 8 9 10 

Test 10 (public)

Subtask: 2, 3

Verdict: ACCEPTED

input
INCREASE A
INCREASE A
INCREASE A
INCREASE A
INCREASE A
...

correct output
5 5 

user output
5 5 

Test 11 (public)

Subtask: 2, 3

Verdict: ACCEPTED

input
INCREASE A
INCREASE A
INCREASE A
INCREASE A
INCREASE A
...

correct output
20 

user output
20 

Test 12 (public)

Subtask: 2, 3

Verdict: ACCEPTED

input
INCREASE A
INCREASE A

INCREASE B
INCREASE B
...

correct output
42 

user output
42 

Test 13 (public)

Subtask: 3

Verdict:

input
INCREASE A
INCREASE A
INCREASE A
INCREASE A
INCREASE A
...

correct output
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 

user output
1 2 3 4 5 

Feedback: Output is shorter than expected

Test 14 (public)

Subtask: 3

Verdict:

input
# Create number 3
INCREASE A INCREASE A INCREASE...

correct output
12 

user output

Feedback: Incorrect character on line 1 col 1: expected "12", got "0"

Test 15 (public)

Subtask: 3

Verdict:

input
INCREASE X
INCREASE X
INCREASE X
INCREASE X
INCREASE X
...

correct output
531441 

user output
1 1 1 1 1 1 1 1 1 

Feedback: Output is longer than expected

Test 16 (public)

Subtask: 3

Verdict:

input
INCREASE A
INCREASE A
INCREASE A
INCREASE A
INCREASE A
...

correct output
1337 

user output
0 0 0 0 0 0 0 0 0 0 0 

Feedback: Output is longer than expected

Test 17 (public)

Subtask: 3

Verdict:

input
INCREASE A
INCREASE A

REPEAT A TIMES (
    REPEAT A TIMES (
...

correct output
1 2 1 2 1 1 3 4 3 4 3 4 3 4 3 ...

user output
0 1 2 2 0 0 2 0 

Feedback: Output is shorter than expected

Test 18 (public)

Subtask: 3

Verdict:

input
# Efficient algorithm for find...

correct output
2 3 5 7 11 13 17 19 23 29 31 3...

user output
(empty)

Feedback: Output is shorter than expected