Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
107228726 Contestant:
wleite
1485D - 16 Java 8 Wrong answer on pretest 2 124 ms 0 KB 2021-02-12 19:49:52 2021-02-12 19:49:53
→ Source
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class D {
    public static void main(String[] args) {
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            String[] s = in.readLine().split(" ");
            int n = Integer.parseInt(s[0]);
            int m = Integer.parseInt(s[1]);
            int[][] arr = new int[n][n];
            for (int i = 0; i < n; i++) {
                s = in.readLine().split(" ");
                for (int j = 0; j < n; j++) {
                    arr[i][j] = Integer.parseInt(s[j]);
                }
            }
            boolean[] ok = new boolean[1000001];
            for (int i = 1; i * i * i * i < ok.length; i++) {
                ok[i * i * i * i] = true;
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    int v = arr[i][j];
                    int up = i == 0 ? -1 : arr[i - 1][j];
                    int left = j == 0 ? -1 : arr[i][j - 1];
                    for (int k = 1;; k++) {
                        int w = v * k;
                        if (w > 1000000) break;
                        if ((up < 0 || ok[Math.abs(w - up)]) && (left < 0 || ok[Math.abs(w - left)])) {
                            arr[i][j] = w;
                            break;
                        }
                    }
                }
            }
            in.close();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (j>0)System.out.print(" ");
                    System.out.print(arr[i][j]);
                }
                System.out.println();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details