CSES - Datatähti 2016 alku - Results
Submission details
Task:Kirjat
Sender:Galax
Submission time:2015-09-30 21:33:56
Language:Java
Status:COMPILE ERROR

Compiler report

input/Main.java:74: error: cannot find symbol
        System.out.println(fuckup);
                           ^
  symbol:   variable fuckup
  location: class Main
1 error

Code

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

public class Main {
    public static void main(String[] args) {
        Scanner io = new Scanner(System.in);
        int books = Integer.parseInt(io.nextLine());
        
        HashMap<Integer, Integer> uo = new HashMap<>();
        String un = io.nextLine();
        String temp = "";
        int pos = 0;
        for (int i = 0; i < un.length(); i++) {
            if (un.charAt(i)==' ') {
                uo.put(pos,Integer.parseInt(temp));
                temp = "";
                pos++;
            } else {
                temp+=un.charAt(i);
            }
            
        }
        uo.put(books-1,Integer.parseInt(temp));
        
        temp = "";
        pos = 0;
        HashMap<Integer, Integer> ma = new HashMap<>();
        String mas = io.nextLine();
        for (int i = 0; i < mas.length(); i++) {
            if (mas.charAt(i)==' ') {
                ma.put(pos,Integer.parseInt(temp));
                temp = "";
                pos++;
            } else {
                temp+=mas.charAt(i);
            }
            
        }
        ma.put(books-1,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);
              
            }
            
            
        }
        //use hashmaps to remove unused cells from it, use while loop?
        tempo2.add(end.indexOf(0));
        //tempo2 includes the positions of 0 ints
        //tempo includes the values not added
        System.out.println(fuckup);
        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++) {
            System.out.print(end.get(i) + " ");
        }
    }
}