CSES - Datatähti 2016 alku - Results
Submission details
Task:Osajono
Sender:Galax
Submission time:2015-09-30 13:19:43 +0300
Language:Java
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.19 s1details
#20.17 s1details
#30.17 s1details
#40.18 s1details
#50.18 s1details
#60.17 s2details
#70.18 s2details
#80.17 s2details
#90.18 s2details
#100.17 s2details
#110.17 s3details
#120.18 s3details
#130.18 s3details
#140.18 s3details
#150.18 s3details

Code

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

public class Ohjelma {
    public static void main(String[] args) {
        IO io = new IO();
        int books = io.nextInt();
        
        ArrayList<Integer> uo = new ArrayList<>();
     /*   String un = io.next();
        String temp = "";
        for (int i = 0; i < un.length(); i++) {
            if (un.charAt(i)==' ') {
                uo.add(Integer.parseInt(temp));
                temp = "";
            } else {
                temp+=un.charAt(i);
            }
            
        }*/
        for (int i = 0; i < books; i++) {
            uo.add(io.nextInt());
        }
        ArrayList<Integer> ma = new ArrayList<>();
        for (int i = 0; i < books; i++) {
            ma.add(io.nextInt());
        }
      /*  uo.add(Integer.parseInt(temp));
        temp = "";
        
        String mas = io.next();
        for (int i = 0; i < mas.length(); i++) {
            if (mas.charAt(i)==' ') {
                ma.add(Integer.parseInt(temp));
                temp = "";
            } else {
                temp+=mas.charAt(i);
            }
            
        }
        ma.add(Integer.parseInt(temp));
        */
        ArrayList<Integer> end = new ArrayList<>();
        for (int i = 0; i < books; i++) {
            end.add(0);
        }
        ArrayList<Integer> tempo = new ArrayList<>();
        ArrayList<Integer> tempo2 = new ArrayList<>();
        for (int i = 0; i < books; i++) {
            Boolean wasAdded = false;
            
            for (int j = 0; j < books; j++) {
                
                if (i+1 != ma.get(j) && i+1 != uo.get(j) && end.get(j)==0) {
                    end.set(j, i+1);
                    wasAdded = true;
                    break;
                }
                
            }
            if (!wasAdded) {
                tempo.add(i+1);
              
            }
            
        }
        for (int i = 0; i < end.size(); i++) {
            if (end.get(i)==0) {
                tempo2.add(i);
            }
        }
        //tempo2 includes the positions of 0 ints
        //tempo includes the values not added
       
        if (tempo.size()!=0) {
            for (int i = 0; i < books; i++) {
                if((tempo.get(0) != ma.get(i) && tempo.get(0) != uo.get(i)) 
                        && ma.get(tempo2.get(0)) != end.get(i) && uo.get(tempo2.get(0)) != end.get(i)) {
                        int tem = end.get(i);
                        end.set(i,tempo.get(0));
                        end.set(tempo2.get(0),tem);
                        break;
                }
            }
        }
       
        for (int i = 0; i < end.size(); i++) {
            io.print(end.get(i) + " ");
        }
    }
}

Test details

Test 1

Group: 1

Verdict:

input
BBBAABBBAAAABBAAAABAABAABBBBBB...

correct output
2554

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 2

Group: 1

Verdict:

input
GDFVYWQCZAFGICSXOSWBZMGPDBSSVL...

correct output
299

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 3

Group: 1

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAZAAAA...

correct output
4314

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 4

Group: 1

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4231

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 5

Group: 1

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
5050

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 6

Group: 2

Verdict:

input
BBABABBBABBAABBABBABAABAAABABA...

correct output
6253029

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 7

Group: 2

Verdict:

input
RBKJMLDVQMKHYKCNDIVVKOMFUXTFMG...

correct output
485173

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 8

Group: 2

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
12427725

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 9

Group: 2

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
12467549

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 10

Group: 2

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
12502500

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 11

Group: 3

Verdict:

input
BAAAAABABBABAABAABABABBBABBAAB...

correct output
2500051369

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 12

Group: 3

Verdict:

input
ABBURXDRVXAYBPXXOQZNYHLWGUEEWR...

correct output
192407124

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 13

Group: 3

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4998050400

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 14

Group: 3

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4998850144

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)

Test 15

Group: 3

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
5000050000

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Ohjelma.main(Ohjelma.java:7)