Task: | Lähetit |
Sender: | |
Submission time: | 2015-07-19 11:44:07 +0300 |
Language: | Java |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.22 s | 1 | details |
#2 | WRONG ANSWER | 0.26 s | 1 | details |
#3 | WRONG ANSWER | 0.24 s | 1 | details |
#4 | WRONG ANSWER | 0.24 s | 1 | details |
#5 | WRONG ANSWER | 0.23 s | 1 | details |
#6 | WRONG ANSWER | 0.33 s | 2 | details |
#7 | TIME LIMIT EXCEEDED | -- | 2 | details |
#8 | WRONG ANSWER | 1.10 s | 2 | details |
#9 | WRONG ANSWER | 1.07 s | 2 | details |
#10 | WRONG ANSWER | 1.10 s | 2 | details |
#11 | TIME LIMIT EXCEEDED | -- | 3 | details |
#12 | TIME LIMIT EXCEEDED | -- | 3 | details |
#13 | TIME LIMIT EXCEEDED | -- | 3 | details |
#14 | TIME LIMIT EXCEEDED | -- | 3 | details |
#15 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
import java.util.Scanner; public class Lahetit { public static int modulo = 1000000007; public static int lautaKoko; public static int lahetit; public static long lautojenLkm = 0; public static void main(String[] args) { Scanner input = new Scanner(System.in); lautaKoko = input.nextInt(); lahetit = input.nextInt(); int[][] lauta = new int[lautaKoko][]; kokeile(lauta); System.out.println(lautojenLkm); } public static void kokeile(int[][] lauta) { for (int i = 0; i < lautaKoko; i++) { lauta[0] = new int[lautaKoko]; lauta[0][i] = 1; kokeile(lauta, 1, 0); } if (lahetit < lautaKoko) { lauta[0] = new int[lautaKoko]; kokeile(lauta, 1, 1); } } public static void kokeile(int[][] lauta, int rivi, int tyhjat) { if (rivi == lautaKoko) return; if (rivi - tyhjat == lahetit) { lautojenLkm += 1; lautojenLkm = lautojenLkm % modulo; return; } for (int i = 0; i < lautaKoko; i++) { if (voiAsettaa(lauta, rivi, i)) { lauta[rivi] = new int[lautaKoko]; lauta[rivi][i] = 1; if (rivi == lautaKoko - 1) { lautojenLkm += 1; lautojenLkm = lautojenLkm % modulo; continue; } kokeile(lauta, rivi+1, tyhjat); } } if (lahetit + tyhjat < lautaKoko) { lauta[rivi] = new int[lautaKoko]; kokeile(lauta, rivi+1, tyhjat+1); } } public static boolean voiAsettaa(int[][] lauta, int rivi, int n) { int offset = 1; for (int i = rivi - 1; i >= 0; i--) { if (n-offset >= 0 && lauta[i][n-offset] == 1) return false; if (n+offset < lautaKoko && lauta[i][n+offset] == 1) return false; offset++; } return true; } public static void tulostaLauta(int[][] lauta) { for (int i = 0; i < lautaKoko; i++) { for (int j = 0; j < lautaKoko; j++) { try { System.out.print(lauta[i][j]); } catch (Exception e) { } } System.out.println(""); } System.out.println(""); } }
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
input |
---|
5 2 |
correct output |
---|
240 |
user output |
---|
190 |
Test 2
Group: 1
Verdict: WRONG ANSWER
input |
---|
5 4 |
correct output |
---|
2728 |
user output |
---|
501 |
Test 3
Group: 1
Verdict: WRONG ANSWER
input |
---|
5 6 |
correct output |
---|
1960 |
user output |
---|
125 |
Test 4
Group: 1
Verdict: WRONG ANSWER
input |
---|
5 8 |
correct output |
---|
32 |
user output |
---|
125 |
Test 5
Group: 1
Verdict: WRONG ANSWER
input |
---|
5 10 |
correct output |
---|
0 |
user output |
---|
125 |
Test 6
Group: 2
Verdict: WRONG ANSWER
input |
---|
10 4 |
correct output |
---|
1809464 |
user output |
---|
896816 |
Test 7
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
10 8 |
correct output |
---|
209594075 |
user output |
---|
(empty) |
Test 8
Group: 2
Verdict: WRONG ANSWER
input |
---|
10 12 |
correct output |
---|
811277399 |
user output |
---|
4834872 |
Test 9
Group: 2
Verdict: WRONG ANSWER
input |
---|
10 16 |
correct output |
---|
17275136 |
user output |
---|
4834872 |
Test 10
Group: 2
Verdict: WRONG ANSWER
input |
---|
10 20 |
correct output |
---|
0 |
user output |
---|
4834872 |
Test 11
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 40 |
correct output |
---|
126883191 |
user output |
---|
(empty) |
Test 12
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 80 |
correct output |
---|
785497039 |
user output |
---|
(empty) |
Test 13
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 120 |
correct output |
---|
324216296 |
user output |
---|
(empty) |
Test 14
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 160 |
correct output |
---|
895190039 |
user output |
---|
(empty) |
Test 15
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100 200 |
correct output |
---|
0 |
user output |
---|
(empty) |