Submission details
Task:Tulkki
Sender:NicholasAhman
Submission time:2025-11-03 16:18:46 +0200
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.00 s1, 2, 3details
#2--1, 2, 3details
#30.00 s1, 2, 3details
#40.00 s1, 2, 3details
#50.00 s1, 2, 3details
#60.00 s1, 2, 3details
#70.00 s2, 3details
#8ACCEPTED0.00 s2, 3details
#90.00 s2, 3details
#100.00 s2, 3details
#110.00 s2, 3details
#120.00 s2, 3details
#130.00 s3details
#140.01 s3details
#150.01 s3details
#160.00 s3details
#170.00 s3details
#180.00 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:100:22: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::array<long unsigned int, 26>::value_type' {aka 'long unsigned int'} [-Wformat=]
  100 |             printf("%d\n", vars[token.data - 'A']);
      |                     ~^
      |                      |
      |                      int
      |                     %ld
input/code.cpp:37:14: warning: ignoring return value of 'char* fgets(char*, int, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         fgets(input, 1024, stdin);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~

Code

#include <array>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdint.h>
#include <vector>

enum class TokenType {
    CLEAR,
    INCREASE,
    PRINT,
    REPEAT,
};

struct Token {
    TokenType type;
    uint64_t data;
};

int trim(char* str, int i) {
    while (isspace(str[i])) {
        i++;
    }

    return i;
}

int main() {
    std::stack<bool> in_repeat;
    std::vector<Token> tokens;

    std::array<uint64_t, 26> vars = {0};

    while (true) {
        char input[1024];
        fgets(input, 1024, stdin);

        int i = 0;
        
        if (input[i] == '\0' or input[i] == '\n' or input[i] == EOF) {
            break;
        }

        i = trim(input, 0);

        if (input[i] == '#') {
            continue;
        }

        Token token;
        token.data = 0;

        bool repeat_added = false;

        printf("%d\n", i);

        if (strncmp(input + i, "CLEAR", 5) == 0) {
            token.type = TokenType::CLEAR;
            i += 5;
        } else if (strncmp(input + i, "INCREASE", 8) == 0) {
            token.type = TokenType::INCREASE;
            i += 8;
        } else if (strncmp(input + i, "PRINT", 5) == 0) {
            printf("Printed\n");
            token.type = TokenType::PRINT;
            i += 5;
        } else if (strncmp(input + i, "REPEAT", 6) == 0) {
            token.type = TokenType::REPEAT;
            i += 6;
            in_repeat.push(true);
            repeat_added = true;
        } else if (input[i] == '(') {
            continue;
        } else if (input[i] == ')') {
            in_repeat.pop();
            continue;
        }

        i = trim(input, i);

        token.data = input[i];
        
        if (repeat_added) {
            i = trim(input, i);
            if (strcmp(input + i, "TIMES") != 0) {
                printf("Error: REPEAT must be followed by TIMES\n");
            }
        }

        tokens.push_back(token);
    }

    for (auto& token : tokens) {
        if (token.type == TokenType::CLEAR) {
            vars[token.data - 'A'] = 0;
        } else if (token.type == TokenType::INCREASE) {
            vars[token.data - 'A']++;
        } else if (token.type == TokenType::PRINT) {
            printf("%d\n", vars[token.data - 'A']);
        } else if (token.type == TokenType::REPEAT) {

        }
    }
}

Test details

Test 1 (public)

Group: 1, 2, 3

Verdict:

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

correct output
0 1 2 0 

user output
(empty)

Test 2 (public)

Group: 1, 2, 3

Verdict:

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

correct output
1 3 

user output
(empty)

Test 3 (public)

Group: 1, 2, 3

Verdict:

input
# Create number 3
INCREASE X
INCREASE X
INCREASE X

...

correct output

user output
0
0
0

Feedback: Output is longer than expected

Test 4 (public)

Group: 1, 2, 3

Verdict:

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
(empty)

Test 5 (public)

Group: 1, 2, 3

Verdict:

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

correct output
999 

user output
(empty)

Test 6 (public)

Group: 1, 2, 3

Verdict:

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
(empty)

Test 7 (public)

Group: 2, 3

Verdict:

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

correct output
5 5 5 5 5 

user output
0
0
0
0
0

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

Test 8 (public)

Group: 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)

Group: 2, 3

Verdict:

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

correct output
6 7 8 9 10 

user output
0
0
0
0
0

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

Test 10 (public)

Group: 2, 3

Verdict:

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

correct output
5 5 

user output
0
0
0
0
0

Feedback: Output is longer than expected

Test 11 (public)

Group: 2, 3

Verdict:

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

correct output
20 

user output
0
0
0
0
0

Feedback: Output is longer than expected

Test 12 (public)

Group: 2, 3

Verdict:

input
INCREASE A
INCREASE A

INCREASE B
INCREASE B
...

correct output
42 

user output
0
0

Feedback: Output is longer than expected

Test 13 (public)

Group: 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
0
0
0
0
0

Feedback: Output is shorter than expected

Test 14 (public)

Group: 3

Verdict:

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

correct output
12 

user output
0

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

Test 15 (public)

Group: 3

Verdict:

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

correct output
531441 

user output
0
0
0
0
0
...

Feedback: Output is longer than expected

Test 16 (public)

Group: 3

Verdict:

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

correct output
1337 

user output
0
0
0
0
0
...

Feedback: Output is longer than expected

Test 17 (public)

Group: 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
0

Feedback: Output is shorter than expected

Test 18 (public)

Group: 3

Verdict:

input
# Efficient algorithm for find...

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

user output
0
0
0
0
0
...

Feedback: Output is longer than expected