Task: | Ruudukko |
Sender: | Jiahao |
Submission time: | 2019-10-06 07:57:11 +0300 |
Language: | Java |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.12 s | details |
#2 | WRONG ANSWER | 0.12 s | details |
#3 | WRONG ANSWER | 0.12 s | details |
#4 | WRONG ANSWER | 0.15 s | details |
#5 | WRONG ANSWER | 0.23 s | details |
#6 | WRONG ANSWER | 0.19 s | details |
Code
import java.util.Scanner; /** * * @author Jiahao Li */ public class Ruudukko { public static void main(String[] args) { Scanner lukija = new Scanner(System.in); int n = Integer.valueOf(lukija.nextLine()); int rivi = 1; if (n % 2 == 1) { //Kaikki luvut yksi eteenpäin while (rivi <= n) { int tulostettu = 0; int tulostettava = rivi; while (tulostettu < n) { System.out.print(tulostettava); tulostettava++; tulostettu++; if (tulostettu != n) { System.out.print(" "); } if (tulostettava > n) { tulostettava = 1; } } System.out.println(""); rivi++; } } else if (n % 2 == 0) { //Parilliset yksi eteenpäin ja parittomat yksi taaksepäin int pariton = rivi; int parillinen = rivi + 1; while (rivi <= n) { int tulostettu = 0; while (tulostettu < n) { if (parillinen > n) { pariton = 1; parillinen = 2; } if (rivi % 2 == 1) { System.out.print(pariton); System.out.print(parillinen); } else { System.out.print(parillinen); System.out.print(pariton); } tulostettu += 2; } System.out.println(""); rivi++; } } } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 2
Verdict: WRONG ANSWER
input |
---|
2 |
correct output |
---|
1 2 2 1 |
user output |
---|
12 21 |
Test 3
Verdict: WRONG ANSWER
input |
---|
5 |
correct output |
---|
1 2 3 4 5 2 1 4 3 6 3 4 1 2 7 4 3 2 1 8 5 6 7 8 1 |
user output |
---|
1 2 3 4 5 2 3 4 5 1 3 4 5 1 2 4 5 1 2 3 5 1 2 3 4 |
Test 4
Verdict: WRONG ANSWER
input |
---|
42 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
121212121212121212121212121212... Truncated |
Test 5
Verdict: WRONG ANSWER
input |
---|
99 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... Truncated |
Test 6
Verdict: WRONG ANSWER
input |
---|
100 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
121212121212121212121212121212... Truncated |