CSES - Datatähti 2022 alku - Results
Submission details
Task:Ositus
Sender:valk
Submission time:2021-10-15 01:33:52 +0300
Language:Java
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.12 s1, 2, 3details
#20.24 s1, 2, 3details
#30.19 s1, 2, 3details
#40.19 s1, 2, 3details
#50.21 s2, 3details
#6--3details
#7--3details

Code


import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) { //remove comments before upload
        Scanner input = new Scanner(System.in);
        
        String msg = input.nextLine(); //msg
        
        ArrayList<String> solutions = new ArrayList<>();
        ArrayList<String> process = new ArrayList<>();
        
        boolean done = false;
        
        //System.out.println("processing msg: " + msg);
        
        process.add(msg);
        
        if(msg.length() == 1) {
        	solutions.add(msg);
        	done = true;
        }
        
        while(!done) {
        	done = true;
        	ArrayList<String> newprocess = new ArrayList<>();
        	for(String proc : process) {
        		//System.out.println("processing possible: " + proc);
        		for(int b = 0; b < proc.length()-1 ; b++) {
        			//System.out.println("b " + proc.substring(b, b+1) + " b1 " + proc.substring(b+1, b+2));
        			if(!proc.substring(b, b+1).contains(",") && !proc.substring(b+1, b+2).contains(",")) {
        				String ns = proc.substring(0, b+1) + "," + proc.substring(b+1, proc.length());
                		//System.out.println("trying: " + ns);
                		if(!process.contains(ns) && !solutions.contains(ns)) {
                			boolean valid = true;
                			for(String s : ns.split(",")) {
                				ArrayList<String> letters = new ArrayList<>();
                				for(int l = 0; l < s.length() ; l++) {
                	        		String letter = s.substring(l,l+1);
                	        		if(!letters.contains(letter)) {
                	        			letters.add(letter);
                	        		}else {
                	        			valid = false;
                	        		}
                	        	}
                			}
                			if(valid) {
                				//System.out.println("valid: " + ns);
                				newprocess.add(ns);
                				solutions.add(ns);
                				done = false;
                			} else {
                				newprocess.add(ns); //way more inefficient, goes through everything until its all , but fixes some issues
                				//System.out.println("invalid: " + ns);
                			}
                		}
        			}
            	}
        	}
        	process = newprocess;
        }
        
        int extra = solutions.size()%10000007;
         
        //System.out.println("done, solution count: " + solutions.size());
        System.out.println(extra);
        
        input.close();
    }
	
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
a

correct output
1

user output
1

Test 2

Group: 1, 2, 3

Verdict:

input
abcdefghij

correct output
512

user output
511

Test 3

Group: 1, 2, 3

Verdict:

input
abcabaacbc

correct output
120

user output
0

Test 4

Group: 1, 2, 3

Verdict:

input
aaxxxxxxaa

correct output
4

user output
0

Test 5

Group: 2, 3

Verdict:

input
mfyzvoxmppoxcvktmcjkryyocfweub...

correct output
643221148

user output
0

Test 6

Group: 3

Verdict:

input
weinscqmmpgbrlboocvtbptgbahmwv...

correct output
831644159

user output
(empty)

Test 7

Group: 3

Verdict:

input
sxaoxcyrjoeieyinaqxwukgzdnhhsw...

correct output
816016015

user output
(empty)