| Task: | Tulkki |
| Sender: | NicholasAhman |
| Submission time: | 2025-11-03 16:34:57 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details |
| #2 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 1, 2, 3 | details |
| #4 | WRONG ANSWER | 0.00 s | 1, 2, 3 | details |
| #5 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
| #6 | ACCEPTED | 0.00 s | 1, 2, 3 | details |
| #7 | WRONG ANSWER | 0.00 s | 2, 3 | details |
| #8 | WRONG ANSWER | 0.00 s | 2, 3 | details |
| #9 | WRONG ANSWER | 0.00 s | 2, 3 | details |
| #10 | WRONG ANSWER | 0.00 s | 2, 3 | details |
| #11 | WRONG ANSWER | 0.00 s | 2, 3 | details |
| #12 | WRONG ANSWER | 0.00 s | 2, 3 | details |
| #13 | WRONG ANSWER | 0.00 s | 3 | details |
| #14 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #15 | WRONG ANSWER | 0.00 s | 3 | details |
| #16 | WRONG ANSWER | 0.00 s | 3 | details |
| #17 | WRONG ANSWER | 0.00 s | 3 | details |
| #18 | TIME LIMIT EXCEEDED | -- | 3 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:107: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=]
107 | printf("%d ", vars[token.data - 'A']);
| ~^
| |
| int
| %ld
input/code.cpp:38:12: warning: unused variable 'len' [-Wunused-variable]
38 | size_t len = read(STDIN_FILENO, input, 128*1000);
| ^~~Code
#include <array>
#include <stack>
#include <stdio.h>
#include <unistd.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};
char input[128*1000];
char *ptr = input;
size_t len = read(STDIN_FILENO, input, 128*1000);
while (true) {
size_t line_end = (size_t)strchr(ptr, '\n');
if (line_end == 0) {
break;
}
line_end -= (size_t)ptr;
int i = 0;
if (ptr[i] == '\0' or ptr[i] == EOF) {
break;
}
i = trim(input, 0);
if (input[i] == '#') {
continue;
}
Token token;
token.data = 0;
bool repeat_added = false;
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) {
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);
ptr += line_end + 1;
}
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 ", vars[token.data - 'A']);
} else if (token.type == TokenType::REPEAT) {
}
}
}
Test details
Test 1 (public)
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| PRINT X INCREASE X PRINT X INCREASE X PRINT X ... |
| correct output |
|---|
| 0 1 2 0 |
| user output |
|---|
| 0 0 0 0 0 0 0 |
Feedback: Output is longer than expected
Test 2 (public)
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| INCREASE X # aybabtu PRINT X INCREASE # test ... |
| correct output |
|---|
| 1 3 |
| user output |
|---|
| (empty) |
Feedback: Output is shorter than expected
Test 3 (public)
Group: 1, 2, 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| # Create number 3 INCREASE X INCREASE X INCREASE X ... |
| correct output |
|---|
| 3 |
| user output |
|---|
| (empty) |
Test 4 (public)
Group: 1, 2, 3
Verdict: WRONG ANSWER
| 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) |
Feedback: Output is shorter than expected
Test 5 (public)
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| INCREASE X INCREASE X INCREASE X INCREASE X INCREASE X ... |
| correct output |
|---|
| 999 |
| user output |
|---|
| (empty) |
Feedback: Output is shorter than expected
Test 6 (public)
Group: 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)
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A ... |
| correct output |
|---|
| 5 5 5 5 5 |
| user output |
|---|
| (empty) |
Feedback: Output is shorter than expected
Test 8 (public)
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A ... |
| correct output |
|---|
| 0 0 0 0 0 |
| user output |
|---|
| (empty) |
Feedback: Output is shorter than expected
Test 9 (public)
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A ... |
| correct output |
|---|
| 6 7 8 9 10 |
| user output |
|---|
| (empty) |
Feedback: Output is shorter than expected
Test 10 (public)
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A ... |
| correct output |
|---|
| 5 5 |
| user output |
|---|
| (empty) |
Feedback: Output is shorter than expected
Test 11 (public)
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A ... |
| correct output |
|---|
| 20 |
| user output |
|---|
| (empty) |
Feedback: Output is shorter than expected
Test 12 (public)
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| INCREASE A INCREASE A INCREASE B INCREASE B ... |
| correct output |
|---|
| 42 |
| user output |
|---|
| (empty) |
Feedback: Output is shorter than expected
Test 13 (public)
Group: 3
Verdict: WRONG ANSWER
| 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 |
|---|
| (empty) |
Feedback: Output is shorter than expected
Test 14 (public)
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| # Create number 3 INCREASE A INCREASE A INCREASE... |
| correct output |
|---|
| 12 |
| user output |
|---|
| (empty) |
Test 15 (public)
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| INCREASE X INCREASE X INCREASE X INCREASE X INCREASE X ... |
| correct output |
|---|
| 531441 |
| user output |
|---|
| (empty) |
Feedback: Output is shorter than expected
Test 16 (public)
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A ... |
| correct output |
|---|
| 1337 |
| user output |
|---|
| (empty) |
Feedback: Output is shorter than expected
Test 17 (public)
Group: 3
Verdict: WRONG ANSWER
| 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 |
|---|
| (empty) |
Feedback: Output is shorter than expected
Test 18 (public)
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| # Efficient algorithm for find... |
| correct output |
|---|
| 2 3 5 7 11 13 17 19 23 29 31 3... |
| user output |
|---|
| (empty) |
