Task: | Shakki |
Sender: | |
Submission time: | 2015-12-06 22:54:16 +0200 |
Language: | Java |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
#4 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.24 s | 1 | details |
#2 | WRONG ANSWER | 0.33 s | 1 | details |
#3 | WRONG ANSWER | 0.28 s | 1 | details |
#4 | WRONG ANSWER | 0.42 s | 1 | details |
#5 | WRONG ANSWER | 0.25 s | 1 | details |
#6 | WRONG ANSWER | 0.23 s | 1 | details |
#7 | WRONG ANSWER | 0.25 s | 1 | details |
#8 | WRONG ANSWER | 0.34 s | 1 | details |
#9 | WRONG ANSWER | 0.25 s | 1 | details |
#10 | WRONG ANSWER | 0.34 s | 1 | details |
#11 | WRONG ANSWER | 0.31 s | 2 | details |
#12 | WRONG ANSWER | 0.26 s | 2 | details |
#13 | WRONG ANSWER | 0.25 s | 2 | details |
#14 | WRONG ANSWER | 0.28 s | 2 | details |
#15 | WRONG ANSWER | 0.25 s | 2 | details |
#16 | WRONG ANSWER | 0.34 s | 2 | details |
#17 | WRONG ANSWER | 0.28 s | 2 | details |
#18 | WRONG ANSWER | 0.27 s | 2 | details |
#19 | WRONG ANSWER | 0.28 s | 2 | details |
#20 | WRONG ANSWER | 0.25 s | 2 | details |
#21 | WRONG ANSWER | 0.22 s | 3 | details |
#22 | WRONG ANSWER | 0.29 s | 3 | details |
#23 | WRONG ANSWER | 0.25 s | 3 | details |
#24 | WRONG ANSWER | 0.23 s | 3 | details |
#25 | WRONG ANSWER | 0.25 s | 3 | details |
#26 | WRONG ANSWER | 0.26 s | 3 | details |
#27 | WRONG ANSWER | 0.27 s | 3 | details |
#28 | WRONG ANSWER | 0.22 s | 3 | details |
#29 | WRONG ANSWER | 0.32 s | 3 | details |
#30 | WRONG ANSWER | 0.27 s | 3 | details |
#31 | WRONG ANSWER | 0.21 s | 4 | details |
#32 | WRONG ANSWER | 0.26 s | 4 | details |
#33 | WRONG ANSWER | 0.25 s | 4 | details |
#34 | WRONG ANSWER | 0.25 s | 4 | details |
#35 | WRONG ANSWER | 0.34 s | 4 | details |
#36 | WRONG ANSWER | 0.23 s | 4 | details |
#37 | WRONG ANSWER | 0.27 s | 4 | details |
#38 | WRONG ANSWER | 0.26 s | 4 | details |
#39 | WRONG ANSWER | 0.28 s | 4 | details |
#40 | WRONG ANSWER | 0.23 s | 4 | details |
Code
//package shakki; import java.util.ArrayList; import java.util.Random; import java.util.Scanner; import java.util.TreeSet; /** * * @author Adreno */ public class Shakki { public static boolean[][] t; public static void main(String[] args) { boolean debug = false; //boolean debug = true; Scanner s = new Scanner(System.in); t = new boolean[8][8]; //TreeSet<Ruutu> collisions = new TreeSet<>(); //int[][] collisions = new int[8][8]; for (int i=0; i<8; i++) { String line = s.next(); for (int j=0; j<8; j++) { if (line.charAt(j) == 'M') t[i][j] = true; if (j>0) { if (line.charAt(j) == line.charAt(j-1)) { //col.add(new Collision(i,j-1, i,j)); } } } } for (int x=0; x<8; x++) { for (int y=1; y<8; y++) { if (t[y-1][x] == t[y][x]) { //col.add(new Collision(y-1,x, y,x)); } } } int score = score(); Random rng = new Random(); ArrayList<String> siirrot = new ArrayList<>(); while (score > 0) { //int index = rng.nextInt(siirrot.size()); int y = rng.nextInt(7); int x = rng.nextInt(7); kaanna(y,x); int newScore = score(); if (newScore > score && rng.nextInt(100) >= 1) { peruKaanto(y,x); } else { score = newScore; siirrot.add(x + " " + y); } //System.out.println("score="+score); } System.out.println(siirrot.size()); if (!debug) { for (String siirto : siirrot) System.out.println(siirto); } } public static void kaanna(int y, int x) { boolean vasenYla = t[y][x]; boolean oikeaYla = t[y][x+1]; boolean vasenAla = t[y+1][x]; boolean oikeaAla = t[y+1][x+1]; t[y][x] = vasenAla; t[y][x+1] = vasenYla; t[y+1][x+1] = oikeaYla; t[y+1][x] = oikeaAla; } public static void peruKaanto(int y, int x) { boolean vasenYla = t[y][x]; boolean oikeaYla = t[y][x+1]; boolean vasenAla = t[y+1][x]; boolean oikeaAla = t[y+1][x+1]; t[y][x] = oikeaYla; t[y][x+1] = oikeaAla; t[y+1][x+1] = vasenAla; t[y+1][x] = vasenYla; } public static int score() { int count = 0; for (int y=1; y<8; y++) { for (int x=1; x<8; x++) { if (t[y][x] == t[y-1][x]) count++; if (t[y][x] == t[y][x-1]) count++; } } for (int x=1; x<8; x++) { if (t[0][x] == t[0][x-1]) count++; } for (int y=1; y<8; y++) { if (t[y][0] == t[y-1][0]) count++; } return count; } public static int scoreAndSaveCollisionSpots() { int count = 0; for (int y=1; y<8; y++) { for (int x=1; x<8; x++) { if (t[y][x] == t[y-1][x]) count++; if (t[y][x] == t[y][x-1]) count++; } } for (int x=1; x<8; x++) { if (t[0][x] == t[0][x-1]) count++; } for (int y=1; y<8; y++) { if (t[y][0] == t[y-1][0]) count++; } return count; } } //class CollisionDB { // public TreeSet<Ruutu> db; // // public CollisionDB() { // this.db = new TreeSet<>(); // } // // public addCollision(int y, int x) { // Ruutu r = new Ruutu(y, x); // Ruutu // } // //} class Ruutu implements Comparable<Ruutu> { public int y; public int x; public int count; public Ruutu(int y, int x) { this.y = y; this.x = x; } @Override public int compareTo(Ruutu o) { if (o.y != this.y) return this.y - o.y; return (this.x - o.x); } } class Collision { public int y1; public int x1; public int y2; public int x2; public Collision(int y1, int x1, int y2, int x2) { this.y1 = y1; this.x1 = x1; this.y2 = y2; this.x2 = x2; } }
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
input |
---|
VMMVVMVV MMVVMVVV MMVVMMMM MVVVMVVM MVVVVMVM ... |
correct output |
---|
100000 |
user output |
---|
784 2 4 3 3 0 6 1 0 ... |
Test 2
Group: 1
Verdict: WRONG ANSWER
input |
---|
MVMVVMMV VVMMVVVV VMMVMMVM MVVVVMVM MVMVMMVM ... |
correct output |
---|
100000 |
user output |
---|
3896 0 2 4 4 3 6 5 0 ... |
Test 3
Group: 1
Verdict: WRONG ANSWER
input |
---|
VMMMVMVV MMMVMVMV VMMVMVVM VVVMVMMV MVMVMVMV ... |
correct output |
---|
100000 |
user output |
---|
1356 1 1 1 6 1 6 6 4 ... |
Test 4
Group: 1
Verdict: WRONG ANSWER
input |
---|
VVVMVMVV VMMVMVMM MVVMMVMV VMVMMVMM MMVVMMVM ... |
correct output |
---|
100000 |
user output |
---|
9091 3 4 2 5 3 6 4 1 ... |
Test 5
Group: 1
Verdict: WRONG ANSWER
input |
---|
MVMVVMMM VVMMVVMV MVVMVVMM VMVMVMMV MMVMVVVM ... |
correct output |
---|
100000 |
user output |
---|
990 5 4 3 1 5 5 5 5 ... |
Test 6
Group: 1
Verdict: WRONG ANSWER
input |
---|
VMMVMVVM VVMMVVMM MMMVMVVM VMMVMMVM MVMVMMMV ... |
correct output |
---|
100000 |
user output |
---|
329 5 4 4 4 6 3 2 1 ... |
Test 7
Group: 1
Verdict: WRONG ANSWER
input |
---|
MVVVVMMM MMMMMMMM VVVVVMMV MMVVMVVM VMVVVVMV ... |
correct output |
---|
100000 |
user output |
---|
1314 5 5 3 6 5 3 3 6 ... |
Test 8
Group: 1
Verdict: WRONG ANSWER
input |
---|
VMMVMVMM MMMVVMMM MVVVVVVV VVVVMMMV MVVVMVVM ... |
correct output |
---|
100000 |
user output |
---|
4225 6 4 1 4 1 6 0 1 ... |
Test 9
Group: 1
Verdict: WRONG ANSWER
input |
---|
VVVVVMMM MMVVVVVV MVVVMMMM VVMVVVVM VMMVMVMM ... |
correct output |
---|
100000 |
user output |
---|
1446 0 1 2 2 6 3 0 3 ... |
Test 10
Group: 1
Verdict: WRONG ANSWER
input |
---|
VMMVMMMM VVMVVVVV VMMVMVMV VMMVMVMM VVVMMMMM ... |
correct output |
---|
100000 |
user output |
---|
4559 3 5 5 6 6 1 6 3 ... |
Test 11
Group: 2
Verdict: WRONG ANSWER
input |
---|
VMVMVVMM MMVMVVMM VMVVVMMV VVVMVMVM VVMMVVMM ... |
correct output |
---|
25000 |
user output |
---|
2838 0 3 2 4 3 1 4 3 ... |
Test 12
Group: 2
Verdict: WRONG ANSWER
input |
---|
MVMVVMVV VMMVVMVM VMVVVMMM VMMMMVVM MMVVVMMM ... |
correct output |
---|
25000 |
user output |
---|
791 6 2 0 1 5 2 0 3 ... |
Test 13
Group: 2
Verdict: WRONG ANSWER
input |
---|
MVVMMVVV MMVVMVMM VVVMVMVV VMVMMMMM MVVMMVMV ... |
correct output |
---|
25000 |
user output |
---|
579 4 4 2 3 0 6 4 4 ... |
Test 14
Group: 2
Verdict: WRONG ANSWER
input |
---|
VVMMMVMV VMVVVMVV VVMVVVMM MVVMVMVM MMVVMMMM ... |
correct output |
---|
25000 |
user output |
---|
2211 3 4 2 2 4 0 5 5 ... |
Test 15
Group: 2
Verdict: WRONG ANSWER
input |
---|
MVVVMVVV MMMMVMMM MVMMMVVM MMVVVMVM VMVVVMMV ... |
correct output |
---|
25000 |
user output |
---|
476 2 5 4 2 3 4 6 3 ... |
Test 16
Group: 2
Verdict: WRONG ANSWER
input |
---|
VMMVMVVM VMMVVVVV MVMVMMVM VMMVVVMV VVMVMMVM ... |
correct output |
---|
25000 |
user output |
---|
4379 2 0 3 5 3 0 4 0 ... |
Test 17
Group: 2
Verdict: WRONG ANSWER
input |
---|
MVVMMVVM MVVVMMMV MVVMMVVM VMMVMVMV VMMVMMMM ... |
correct output |
---|
25000 |
user output |
---|
2036 6 3 1 1 6 6 0 2 ... |
Test 18
Group: 2
Verdict: WRONG ANSWER
input |
---|
MVMMVVMM VVMMMMVV VMVVVVVM MVMMMVMV VMVVVMVM ... |
correct output |
---|
25000 |
user output |
---|
2480 0 5 5 1 3 4 3 5 ... |
Test 19
Group: 2
Verdict: WRONG ANSWER
input |
---|
MVVVVVVV VMMVMVVM VMVMMMMV MVMVMMMM MMVVVMMM ... |
correct output |
---|
25000 |
user output |
---|
2126 2 0 6 4 4 5 2 6 ... |
Test 20
Group: 2
Verdict: WRONG ANSWER
input |
---|
MVVVMMMM MMVMMVMV MVVVVVMM VVMMMVVM VVVMVMVV ... |
correct output |
---|
25000 |
user output |
---|
829 2 2 1 1 6 1 0 2 ... |
Test 21
Group: 3
Verdict: WRONG ANSWER
input |
---|
VMVVMVMM MMMMVMMV VVVMVVVV MVMVMVVM VMMVMMMM ... |
correct output |
---|
5000 |
user output |
---|
213 4 2 4 5 5 5 4 4 ... |
Test 22
Group: 3
Verdict: WRONG ANSWER
input |
---|
VVVVVVMM MMMVMMVV VVVVVVMV MMMVMVVV MVVMMMMV ... |
correct output |
---|
5000 |
user output |
---|
2795 5 1 2 0 1 6 1 4 ... |
Test 23
Group: 3
Verdict: WRONG ANSWER
input |
---|
MMVMVMVV MMVVMVVM VMMVVMVM MMMMMMVV MVVVVMVM ... |
correct output |
---|
5000 |
user output |
---|
509 3 6 6 5 5 2 4 4 ... |
Test 24
Group: 3
Verdict: WRONG ANSWER
input |
---|
MVMVVMVM VVMVVMVM MMMMVMVV MVVMMVVV MMMMMVVV ... |
correct output |
---|
5000 |
user output |
---|
385 6 4 5 3 2 2 0 6 ... |
Test 25
Group: 3
Verdict: WRONG ANSWER
input |
---|
MVVVMVVM MMMMVVMV VMMVMMVV VVMVMVMV MVMMMVMM ... |
correct output |
---|
5000 |
user output |
---|
1095 4 4 3 1 0 3 3 4 ... |
Test 26
Group: 3
Verdict: WRONG ANSWER
input |
---|
VMVMVVVM MMMVVVMM MMVVVVVM VVVVMMVV VMMVVMMV ... |
correct output |
---|
5000 |
user output |
---|
1725 1 3 3 0 4 4 3 0 ... |
Test 27
Group: 3
Verdict: WRONG ANSWER
input |
---|
MMVMMVVM MVVVMVMV MVVVMVVM VMVMMMVV VMMVVVVV ... |
correct output |
---|
5000 |
user output |
---|
2437 2 4 2 5 5 2 6 2 ... |
Test 28
Group: 3
Verdict: WRONG ANSWER
input |
---|
MVMMVMMV VMVMMMVV MMMMVVMV VVVVMMMM MMMVMMVV ... |
correct output |
---|
5000 |
user output |
---|
275 6 0 5 4 1 6 6 1 ... |
Test 29
Group: 3
Verdict: WRONG ANSWER
input |
---|
VVVVMVMV MMMVVMVM MVVVMVMV VVVMVVMM VMMMMMVV ... |
correct output |
---|
5000 |
user output |
---|
4090 4 5 2 1 1 0 2 0 ... |
Test 30
Group: 3
Verdict: WRONG ANSWER
input |
---|
MVVVMVVV MMVVMMMM MVVVVVVV MVMVMMMV VMMMVMMM ... |
correct output |
---|
5000 |
user output |
---|
1909 5 2 3 0 5 2 5 3 ... |
Test 31
Group: 4
Verdict: WRONG ANSWER
input |
---|
MVMMVMMV VVVMMVVV VMMVVMMV VVMMMVVM VVVMMMVV ... |
correct output |
---|
250 |
user output |
---|
217 4 3 2 6 4 1 2 4 ... |
Test 32
Group: 4
Verdict: WRONG ANSWER
input |
---|
VVMMVVVM VMVVMMVV VMMMMMMV VVMVMVVV VMMVMVMM ... |
correct output |
---|
250 |
user output |
---|
1147 4 4 5 1 3 0 3 2 ... |
Test 33
Group: 4
Verdict: WRONG ANSWER
input |
---|
MMVVMVMV VVVMVMMM VVVVMVMM MVVMVVMV VMMVMVVM ... |
correct output |
---|
250 |
user output |
---|
1501 2 3 6 3 6 3 4 3 ... |
Test 34
Group: 4
Verdict: WRONG ANSWER
input |
---|
VMVMVVMV MVVMMMMM MMVVMMMM VMVMVVVM VMMMVVVM ... |
correct output |
---|
250 |
user output |
---|
716 1 2 3 0 4 0 4 6 ... |
Test 35
Group: 4
Verdict: WRONG ANSWER
input |
---|
VMVMVMMM VMMVVVMM MMVMVMMM MVMMVVVV VMMVMMMV ... |
correct output |
---|
250 |
user output |
---|
4673 0 3 5 4 5 4 4 3 ... |
Test 36
Group: 4
Verdict: WRONG ANSWER
input |
---|
MVMVMVMM MVMVMMMV MMVVVVMM MVMVVVVV VMMMVVMM ... |
correct output |
---|
250 |
user output |
---|
891 3 1 2 4 0 3 2 1 ... |
Test 37
Group: 4
Verdict: WRONG ANSWER
input |
---|
VMMMMVMM VVMMMVMV VMVVVVVV MVMMMVVM VMVMMVVM ... |
correct output |
---|
250 |
user output |
---|
2309 2 2 2 5 4 4 5 2 ... |
Test 38
Group: 4
Verdict: WRONG ANSWER
input |
---|
VMMVMVMV VVMVMVMM MMMVMVMM MVVVVMMM MMVVVMVV ... |
correct output |
---|
250 |
user output |
---|
1731 5 2 3 2 0 1 1 5 ... |
Test 39
Group: 4
Verdict: WRONG ANSWER
input |
---|
MMMMMVMV MVVMMMMV VMVVVVMM VMVVVMMV MVMMMVMM ... |
correct output |
---|
250 |
user output |
---|
2161 0 6 1 2 3 4 6 2 ... |
Test 40
Group: 4
Verdict: WRONG ANSWER
input |
---|
VMMMMMMV VMMVVVVV MVMMVMMV MVVVVMMV MVVVVMMM ... |
correct output |
---|
250 |
user output |
---|
490 1 3 3 6 6 2 1 0 ... |