Submission details
Task:Tulkki
Sender:DataN29
Submission time:2025-10-29 12:25:44 +0200
Language:Java
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.13 s1, 2, 3details
#20.13 s1, 2, 3details
#30.13 s1, 2, 3details
#40.15 s1, 2, 3details
#50.22 s1, 2, 3details
#60.23 s1, 2, 3details
#70.13 s2, 3details
#80.14 s2, 3details
#90.14 s2, 3details
#100.14 s2, 3details
#110.14 s2, 3details
#120.14 s2, 3details
#130.14 s3details
#140.14 s3details
#150.14 s3details
#160.14 s3details
#170.14 s3details
#180.19 s3details

Code

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Thulk tulkki=new Thulk();
        tulkki.activate();
    }
}

final class Thulk {
    
    public Thulk(){
        int a=0;
    }
    public void activate(){
        Repeat repeat=new Repeat();
        Scanner scan=new Scanner(System.in);
        
        while (true){
            String cod=scan.nextLine();
            ArrayList<String> exec=new ArrayList<>();
            String[] temp=cod.split(" ");
            int temp2=0;
            ArrayList<String> temp3=new ArrayList<>();
            String temp4="";
            int temp5=0;
            boolean temp6=false;
            for (int i=0;i<temp.length;i++){
                exec.add(temp[i]);
            }
            
            if (exec.get(0).equals("#")){
                exec.clear();
            } else {
                while (exec.size()>1){
                    if (repeat.repeat.variabIndex.indexOf(exec.get(1))==-1&&!exec.get(1).equals(")")){
                        repeat.repeat.variabIndex.add(exec.get(1));
                        repeat.repeat.variab.add(0);
                    }
                    while (exec.get(0).equals(")")){
                        exec.remove(0);
                    }
                    if (exec.get(0).equals("CLEAR")){
                        repeat.repeat.variab.set(repeat.repeat.variabIndex.indexOf(exec.get(1)),0);
                        
                    } else if (exec.get(0).equals("INCREASE")){
                        repeat.repeat.variab.set(repeat.repeat.variabIndex.indexOf(exec.get(1)),repeat.repeat.variab.get(repeat.repeat.variabIndex.indexOf(exec.get(1)))+1);
                    } else if (exec.get(0).equals("PRINT")){
                        System.out.println(repeat.repeat.variab.get(repeat.repeat.variabIndex.indexOf(exec.get(1))));
                    } else if (exec.get(0).equals("REPEAT")){
                        temp5=0;
                        temp6=false;
                        for (int k=0;k<exec.size();k++){
                            if (exec.get(k).equals("(")){
                                temp5+=1;
                                temp6=true;
                            } else if (exec.get(k).equals(")")){
                                temp5-=1;
                            }
                            if (temp5==0&&temp6){
                                temp5=k;
                                break;
                            }
                        }
                        for (int j=4; j<temp5+1;j++){
                            temp3.add(exec.get(j));
                        }
                        temp4=exec.get(1);
                        exec.remove(0);
                        exec.remove(0);
                        exec.remove(0);
                        exec.remove(0);
                        repeat.execute(repeat.repeat.variab.get(repeat.repeat.variabIndex.indexOf(temp4)), temp3,false);
                        temp2=exec.indexOf(")");
                        for (int k=0;k<temp2;k++){
                            exec.remove(0);
                        }

                    }
                    try{
                    if (exec.get(0).equals("REPEAT")||exec.get(0).equals(")")){
                        exec.remove(0);
                    } else {
                        exec.remove(0);
                        exec.remove(0);
                    }
                    }catch (IndexOutOfBoundsException e){
                        ;
                    }
                }
            }
        }
    }
}


final class Repeat {
    public Recurepeat repeat=new Recurepeat();
    private ArrayList<String> save=new ArrayList<>();
    public Repeat(){
        int a=1;
    }
    public void execute(int rebst,ArrayList<String> commands, boolean recurs){
        save.clear();
        for (int i=0;i<commands.size();i++){
            this.save.add(commands.get(i));
        }
        int repeats=rebst;
        
        ArrayList<String> temp3=new ArrayList<>();
        String temp4="";
        int temp5=0;
        boolean temp6=false;
        while (repeats>0){
            commands.clear();
            for (int i=0;i<save.size();i++){
                commands.add(save.get(i));
            }
            while (commands.size()>1){
                if (repeat.variabIndex.indexOf(commands.get(1))==-1&&!commands.get(1).equals(")")){
                    repeat.variabIndex.add(commands.get(1));
                    repeat.variab.add(0);
                }
                if (commands.get(0).equals("CLEAR")){
                    repeat.variab.set(repeat.variabIndex.indexOf(commands.get(1)),0);
                    
                } else if (commands.get(0).equals("INCREASE")){
                    repeat.variab.set(repeat.variabIndex.indexOf(commands.get(1)),repeat.variab.get(repeat.variabIndex.indexOf(commands.get(1)))+1);
                } else if (commands.get(0).equals("PRINT")){
                    System.out.println(repeat.variab.get(repeat.variabIndex.indexOf(commands.get(1))));
                } else if (commands.get(0).equals("REPEAT")){
                    temp5=0;
                    temp6=false;
                    for (int k=0;k<commands.size();k++){
                        if (commands.get(k).equals("(")){
                            temp5+=1;
                            temp6=true;
                        } else if (commands.get(k).equals(")")){
                            temp5-=1;
                        }
                        if (temp5==0&&temp6){
                            temp5=k;
                            break;
                        }
                    }
                    for (int j=4; j<temp5+1;j++){
                        temp3.add(commands.get(j));
                    }
                    temp4=commands.get(1);
                    commands.remove(0);
                    commands.remove(0);
                    commands.remove(0);
                    commands.remove(0);
                    repeat.execute(repeat.variab.get(repeat.variabIndex.indexOf(temp4)), temp3,false);

                }
                try{
                    if (commands.get(0).equals("REPEAT")||commands.get(0).equals(")")){
                        commands.remove(0);
                    } else {
                        commands.remove(0);
                        commands.remove(0);
                    }
                    }catch (IndexOutOfBoundsException e){
                        ;
                }
            }
            
            repeats-=1;
        }

    }
}

final class Recurepeat {
    public ArrayList<Integer> variab=new ArrayList<>();
    public ArrayList<String> variabIndex=new ArrayList<>();
    private ArrayList<String> save=new ArrayList<>();;
    public Recurepeat(){
        int a=1;
    }
    public void execute(int rebst,ArrayList<String> commands, boolean recurs){
        save.clear();
        for (int i=0;i<commands.size();i++){
            this.save.add(commands.get(i));
        }
        int repeats=rebst;
        Repeat repeat=new Repeat();
        ArrayList<String> temp3=new ArrayList<>();
        String temp4="";
        int temp5=0;
        boolean temp6=false;
        while (repeats>0){
            commands.clear();
            for (int i=0;i<save.size();i++){
                commands.add(save.get(i));
            }
            while (commands.size()>1){
                if (variabIndex.indexOf(commands.get(1))==-1&&!commands.get(1).equals(")")){
                    variabIndex.add(commands.get(1));
                    variab.add(0);
                }
                if (commands.get(0).equals("CLEAR")){
                    variab.set(variabIndex.indexOf(commands.get(1)),0);
                    
                } else if (commands.get(0).equals("INCREASE")){
                    variab.set(variabIndex.indexOf(commands.get(1)),variab.get(variabIndex.indexOf(commands.get(1)))+1);
                    System.out.println("debug");
                } else if (commands.get(0).equals("PRINT")){
                    System.out.println(variab.get(variabIndex.indexOf(commands.get(1))));
                } else if (commands.get(0).equals("REPEAT")){
                    temp5=0;
                    temp6=false;
                    for (int k=0;k<commands.size();k++){
                        if (commands.get(k).equals("(")){
                            temp5+=1;
                            temp6=true;
                        } else if (commands.get(k).equals(")")){
                            temp5-=1;
                        }
                        if (temp5==0&&temp6){
                            temp5=k;
                            break;
                        }
                    }
                    for (int j=4; j<temp5+1;j++){
                        temp3.add(commands.get(j));
                    }
                    temp4=commands.get(1);
                    commands.remove(0);
                    commands.remove(0);
                    commands.remove(0);
                    commands.remove(0);
                    repeat.execute(variab.get(variabIndex.indexOf(temp4)), temp3,false);

                }
                try{
                    if (commands.get(0).equals("REPEAT")||commands.get(0).equals(")")){
                        commands.remove(0);
                    } else {
                        commands.remove(0);
                        commands.remove(0);
                    }
                }catch (IndexOutOfBoundsException e){
                        ;
                }
            }
            
            repeats-=1;
        }

    }
}

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

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

Test 2 (public)

Group: 1, 2, 3

Verdict:

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

correct output
1 3 

user output
(empty)

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

Test 3 (public)

Group: 1, 2, 3

Verdict:

input
# Create number 3
INCREASE X
INCREASE X
INCREASE X

...

correct output

user output
3

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

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

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

Test 5 (public)

Group: 1, 2, 3

Verdict:

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

correct output
999 

user output
999

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

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

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

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
5

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

Test 8 (public)

Group: 2, 3

Verdict:

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

correct output
0 0 0 0 0 

user output
0

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

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
6

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

Test 10 (public)

Group: 2, 3

Verdict:

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

correct output
5 5 

user output
1
1

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

Test 11 (public)

Group: 2, 3

Verdict:

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

correct output
20 

user output
7

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

Test 12 (public)

Group: 2, 3

Verdict:

input
INCREASE A
INCREASE A

INCREASE B
INCREASE B
...

correct output
42 

user output
8

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

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
1

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

Test 14 (public)

Group: 3

Verdict:

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

correct output
12 

user output
debug
debug
debug
debug
debug
...

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

Test 15 (public)

Group: 3

Verdict:

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

correct output
531441 

user output
1

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

Test 16 (public)

Group: 3

Verdict:

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

correct output
1337 

user output
1

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

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

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)

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

Error:
Exception in thread "main" java.util.NoSuchElementException: No line found
	at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
	at Thulk.activate(Main.java:21)
	at Main.main(Main.java:7)