Submission details
Task:Tulkki
Sender:R0B0R0BO
Submission time:2025-11-01 12:53:15 +0200
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED12
#2ACCEPTED32
#3ACCEPTED56
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2, 3details
#2ACCEPTED0.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.02 s3details
#16ACCEPTED0.00 s3details
#17ACCEPTED0.06 s3details
#18ACCEPTED0.01 s3details

Compiler report

input/code.cpp: In function 'int KayKomentojaLapi(int, int)':
input/code.cpp:45: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]
   45 |     for (int i = aloituskohta; i < komentolista.size(); i++)
      |                                ~~^~~~~~~~~~~~~~~~~~~~~
input/code.cpp:97:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |                     for (int j = i; j < komentolista.size(); j++)
      |                                     ~~^~~~~~~~~~~~~~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:161:25: warning: unused variable 'testausasia' [-Wunused-variable]
  161 |                     int testausasia = 0;
      |                         ^~~~~~~~~~~
input/code.cpp:156:35: warning: 'edellineTyhja' may be used uniniti...

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 << " ";
}
//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 
vector<pair<int,int>> komentolista;
//Muistiosote ja sen arvo
map<int,int> muisti;
 
 
void LisaaKomentoListaan(pair<int,int> komento){
    komentolista.push_back(komento);
}

int komentoNro = 0;
 
int KayKomentojaLapi(int aloituskohta, int syvyys){
    for (int i = aloituskohta; i < komentolista.size(); i++)
    {
        /*
        if(i == 39){
            cout << "loop jonka ei pitäis mennä";
        }
        if(i== 41){
            cout << "perill' 'nice trickissä' ";
        }
        if(i == 58){
            cout << "perillä L ";
        }
        if(i == 70){
            cout << "perillä I ";
        }
        if(i == 81){
            cout << "eka print";
        }
        //cout << i << " ";
        if(komentoNro == 10e6){
            cout << "Joo o nyt tuli 1 000 000 täytee. Ihan vaan muuten vaan syvyys: " << syvyys << "\n";
            return -1;
        }
        else{
            komentoNro++;
        }
        */

       // 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 = -1;
                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);
                }

                if(paljoTuleeSkippaa == -1){
                    for (int j = i; j < komentolista.size(); j++)
                    {
                        if(komentolista[j].first == 5 && komentolista[j].second == syvyys+1){
                            paljoTuleeSkippaa = j;
                            break;
                        }
                    }
                    
                }

                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;
 
    bool luetteleeKomentoja = true;
    string komento = "";
    char arvo = 0;
    bool edellineTyhja;
    bool skipPls = false;
 
    while ( getline(cin, line))
    {
        if(line == "ä") {break;}
 
        if(komento != "") {luetteleeKomentoja = false;}
        else { luetteleeKomentoja = true;}
 
 
 
        for (auto &&c : line)
        {
            if(c == 35) {skipPls = true; break;}
            if(c == 32){
                
                if(luetteleeKomentoja == false && arvo != 0){
                    if(komento == "PRINT") {LisaaKomentoListaan(make_pair(2,arvo)); komento = ""; luetteleeKomentoja = true;}
                    if(komento == "INCREASE") {LisaaKomentoListaan(make_pair(1,arvo)); komento = ""; luetteleeKomentoja = true;}
                    if(komento == "CLEAR") {LisaaKomentoListaan(make_pair(0,arvo)); komento = ""; luetteleeKomentoja = true;}
                }
 
                if(!edellineTyhja && komento != ""){
                    
                    luetteleeKomentoja = !luetteleeKomentoja;
                }
                else{
                    int testausasia = 0;
                }
 
 
                edellineTyhja = true;
 
 
            }
            else if(c == 40){
                LisaaKomentoListaan(make_pair(4,arvo));
                syvyys += 1;
                komento = "";
                luetteleeKomentoja = true;
                edellineTyhja = false;
            }
            else if(c == 41){
                LisaaKomentoListaan(make_pair(5,syvyys));
                syvyys -= 1;
                edellineTyhja = false;
            }
 
            else if(luetteleeKomentoja){
                komento += c;
                edellineTyhja = false;
            }
 
            
            else{
                arvo = c - 64;
                edellineTyhja = false;
            }
 
        }
 
        if(!skipPls){
            if(luetteleeKomentoja == false && !(arvo == 0)){
                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 = "";}
            }   
        
            arvo = 0;
        }
        else{
            skipPls = false;
        }
 
    }
   /* 
    for (int i = 0; i < komentolista.size(); i++)
    {
        string ulos = "";

        switch (komentolista[i].first)
        {
        case 0:
            ulos = "CLEAR";
            break;
        case 1:
            ulos = "INCREASE";
            break;
        case 2:
            ulos = "PRINT";
            break;
        case 4:
            ulos = "(";
            break;
        case 5:
            ulos = ") --";
            break;
        
        default:
            break;
        }
        cout << ulos << " " << char(komentolista[i].second+64) << "\n" ;
    }
    */

    for (int i = 0; i <= 26; i++)
    {
        muisti[i] = 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: ACCEPTED

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

correct output
1 3 

user output
1 3 

Test 3 (public)

Group: 1, 2, 3

Verdict: ACCEPTED

input
# Create number 3
INCREASE X
INCREASE X
INCREASE X

...

correct output

user output

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 1 1 1 1 1 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 0 0 0 0 0 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 3 4 4 4 4 5 5 5 5 5 

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 1 3 4 3 4 3 4 3 4 3 ...

Test 18 (public)

Group: 3

Verdict: ACCEPTED

input
# Efficient algorithm for find...

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

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