Submission details
Task:Tulkki
Sender:R0B0R0BO
Submission time:2025-10-28 21:45:22 +0200
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2, 3details
#20.00 s1, 2, 3details
#3ACCEPTED0.00 s1, 2, 3details
#4ACCEPTED0.00 s1, 2, 3details
#5ACCEPTED0.00 s1, 2, 3details
#6ACCEPTED0.00 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
#13ACCEPTED0.00 s3details
#14ACCEPTED0.00 s3details
#15ACCEPTED0.01 s3details
#16ACCEPTED0.00 s3details
#17ACCEPTED0.05 s3details
#180.62 s3details

Compiler report

input/code.cpp: In function 'int KayKomentojaLapi(int, int)':
input/code.cpp:43:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (int i = aloituskohta; i < komentolista.size(); i++)
      |                                ~~^~~~~~~~~~~~~~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:142:13: warning: unused variable 'variable' [-Wunused-variable]
  142 |         int variable = 0;
      |             ^~~~~~~~

Code

#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <optional>
#include <string>


typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned int uint;

using namespace std;

//2
void Print(int x){
    cout << x << "\n";
}
//1
int Increase(int x){
    return x += 1;
}
//0
int Clear(){
    return 0;
}

//Teorias opcode ja sit arvo
// 0 Clear, 1 INC, 2 PRNT, 3 ?, 4+syvyys LOOP ALKU, 5+syvyys LOOP LOPPU (ja tän arvo on sit turha)
vector<pair<int,int>> komentolista;
//Muistiosote ja sen arvo
map<char,int> muisti;


void LisaaKomentoListaan(pair<int,int> komento){
    komentolista.push_back(komento);
}

int KayKomentojaLapi(int aloituskohta, int syvyys){
    for (int i = aloituskohta; i < komentolista.size(); i++)
    {
       // cout << komentolista[i].first << " ";
        switch (komentolista[i].first)
            {
            case 0:
                muisti[komentolista[i].second] = Clear();
                break;
            case 1:
                muisti[komentolista[i].second] = Increase(muisti[komentolista[i].second]);
                break;
            case 2:
                Print(muisti[komentolista[i].second]);
                break;
            case 4:
            {
                //int max = komentolista.size() - i;
                int spotti = i;
                int paljoTuleeSkippaa = 0;
                int montakoKierrosta = muisti[komentolista[i].second];  //Tämä, jotta ei voisi lisätä kierroksia sisältä
                for (int j = 0; j < montakoKierrosta; j++)
                {
                    paljoTuleeSkippaa = KayKomentojaLapi(spotti+1,syvyys+1);
                }
                i = paljoTuleeSkippaa;
                break;
            }
            case 5:
            if(komentolista[i].second == syvyys){
                return i;
            }
            break;

            default:
                cout << "VIRHE!!";
                break;
        }
    }

    return 0;
}

int main(){

    string line = "";
    int syvyys = 0;

    while ( getline(cin, line))
    {
        if(line == "ä") {break;}


        string komento = "";
        char arvo = 0;

        bool luetteleeKomentoja = true;


        for (auto &&c : line)
        {
            if(c == 35) {break;}
            if(c == 32){
                if(luetteleeKomentoja == false){
                    if(komento == "PRINT") {LisaaKomentoListaan(make_pair(2,arvo)); komento = "";}
                    if(komento == "INCREASE") {LisaaKomentoListaan(make_pair(1,arvo)); komento = "";}
                    if(komento == "CLEAR") {LisaaKomentoListaan(make_pair(0,arvo)); komento = "";}
                }

                luetteleeKomentoja = !luetteleeKomentoja;

            }
            else if(c == 40){
                LisaaKomentoListaan(make_pair(4,arvo));
                syvyys += 1;
                komento = "";
            }
            else if(c == 41){
                LisaaKomentoListaan(make_pair(5,syvyys));
                syvyys -= 1;
            }

            else if(luetteleeKomentoja)
                komento += c;
            
            else{
                arvo = c - 65;
                
            }

        }
        
        if(luetteleeKomentoja == false){
            if(komento == "PRINT") {LisaaKomentoListaan(make_pair(2,arvo));}
            if(komento == "INCREASE") {LisaaKomentoListaan(make_pair(1,arvo));}
            if(komento == "CLEAR") {LisaaKomentoListaan(make_pair(0,arvo));}
        }        
        
       
        string command = "";
        int variable = 0;
    }

   
    KayKomentojaLapi(0,0);


    return 0;
}

Test details

Test 1 (public)

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

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

Group: 1, 2, 3

Verdict: ACCEPTED

input
# Create number 3
INCREASE X
INCREASE X
INCREASE X

...

correct output

user output
3

Test 4 (public)

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

Test 5 (public)

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

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
...

Test 7 (public)

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

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

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

Group: 2, 3

Verdict: ACCEPTED

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

correct output
20 

user output
20

Test 12 (public)

Group: 2, 3

Verdict: ACCEPTED

input
INCREASE A
INCREASE A

INCREASE B
INCREASE B
...

correct output
42 

user output
42

Test 13 (public)

Group: 3

Verdict: ACCEPTED

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
2
3
3
...

Test 14 (public)

Group: 3

Verdict: ACCEPTED

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

correct output
12 

user output
12

Test 15 (public)

Group: 3

Verdict: ACCEPTED

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

correct output
531441 

user output
531441

Test 16 (public)

Group: 3

Verdict: ACCEPTED

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

correct output
1337 

user output
1337

Test 17 (public)

Group: 3

Verdict: ACCEPTED

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
1
2
1
2
1
...

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