CSES - Datatähti 2020 alku - Results
Submission details
Task:Ruudukko
Sender:matskuman5
Submission time:2019-10-09 19:45:19 +0300
Language:Assembly
Status:COMPILE ERROR

Compiler report

input/code.asm:2: error: parser: instruction expected
input/code.asm:4: error: parser: instruction expected
input/code.asm:6: error: label or instruction expected at start of line
input/code.asm:7: error: label or instruction expected at start of line
input/code.asm:8: error: label or instruction expected at start of line
input/code.asm:9: error: symbol `public' redefined
input/code.asm:9: error: parser: instruction expected
input/code.asm:11: error: parser: instruction expected
input/code.asm:13: error: comma, colon, decorator or end of line expected after operand
input/code.asm:15: error: expression syntax error
input/code.asm:16: error: comma, colon, decorator or end of line expected after operand
input/code.asm:19: error: parser: instruction expected
input/code.asm:21: error: symbol `for' redefined
input/code.asm:21: error: parser: instruction expected
input/code.asm:23: error: parser: instruction expected
input/code.asm:24: error: parser: instruction expected
input/code.asm:25: wa...

Code

import java.util.Scanner;

public class Datatahti {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Scanner lukija = new Scanner(System.in);
        
        int n = Integer.valueOf(lukija.nextLine());
        
        int[][] ruudukko = new int[n][n];
        int lisattavaNumero = 1;
        
        
        for (int rivi = 0; rivi < n; rivi++) {
            
            for (int sarake = 0; sarake < n; sarake++) {
                
                if (rivi == 0 && sarake == 0) {
                    ruudukko[rivi][0] = 1;
                    continue;
                }
                
                while (true) {
                    boolean reset = false;
                    
                    for (int s = 0; s < sarake; s++) {
                        if (lisattavaNumero == ruudukko[rivi][s]) {
                            reset = true;
                        }
                    }
                    
                    if (rivi > 0) {
                        for (int r = 0; r < rivi; r++) {
                            if (lisattavaNumero == ruudukko[r][sarake]) {
                                reset = true;
                            }
                        }
                    }
                    
                    if (reset) {
                        lisattavaNumero++;
                        continue;
                    } else {
                        break;
                    }
                }
                
                ruudukko[rivi][sarake] = lisattavaNumero++;
                
                lisattavaNumero = 1;
                
            }
            
            
        }
        
        
        StringBuilder rakentaja;
        
        for (int rivi = 0; rivi < n; rivi++) {
            rakentaja = new StringBuilder();
            for (int sarake = 0; sarake < n; sarake++) {
                rakentaja.append(ruudukko[rivi][sarake]);
                rakentaja.append(" ");
            }
            System.out.println(rakentaja.toString());
        }
        
    }
    
}