Task: | Shakki |
Sender: | |
Submission time: | 2015-12-06 23:07:02 +0200 |
Language: | Java |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | TIME LIMIT EXCEEDED | 0 |
#2 | TIME LIMIT EXCEEDED | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
#4 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | TIME LIMIT EXCEEDED | -- | 1 | details |
#2 | TIME LIMIT EXCEEDED | -- | 1 | details |
#3 | TIME LIMIT EXCEEDED | -- | 1 | details |
#4 | TIME LIMIT EXCEEDED | -- | 1 | details |
#5 | TIME LIMIT EXCEEDED | -- | 1 | details |
#6 | TIME LIMIT EXCEEDED | -- | 1 | details |
#7 | TIME LIMIT EXCEEDED | -- | 1 | details |
#8 | TIME LIMIT EXCEEDED | -- | 1 | details |
#9 | TIME LIMIT EXCEEDED | -- | 1 | details |
#10 | TIME LIMIT EXCEEDED | -- | 1 | details |
#11 | TIME LIMIT EXCEEDED | -- | 2 | details |
#12 | TIME LIMIT EXCEEDED | -- | 2 | details |
#13 | TIME LIMIT EXCEEDED | -- | 2 | details |
#14 | TIME LIMIT EXCEEDED | -- | 2 | details |
#15 | TIME LIMIT EXCEEDED | -- | 2 | details |
#16 | TIME LIMIT EXCEEDED | -- | 2 | details |
#17 | TIME LIMIT EXCEEDED | -- | 2 | details |
#18 | TIME LIMIT EXCEEDED | -- | 2 | details |
#19 | TIME LIMIT EXCEEDED | -- | 2 | details |
#20 | TIME LIMIT EXCEEDED | -- | 2 | details |
#21 | TIME LIMIT EXCEEDED | -- | 3 | details |
#22 | TIME LIMIT EXCEEDED | -- | 3 | details |
#23 | TIME LIMIT EXCEEDED | -- | 3 | details |
#24 | TIME LIMIT EXCEEDED | -- | 3 | details |
#25 | TIME LIMIT EXCEEDED | -- | 3 | details |
#26 | TIME LIMIT EXCEEDED | -- | 3 | details |
#27 | TIME LIMIT EXCEEDED | -- | 3 | details |
#28 | TIME LIMIT EXCEEDED | -- | 3 | details |
#29 | TIME LIMIT EXCEEDED | -- | 3 | details |
#30 | TIME LIMIT EXCEEDED | -- | 3 | details |
#31 | TIME LIMIT EXCEEDED | -- | 4 | details |
#32 | TIME LIMIT EXCEEDED | -- | 4 | details |
#33 | TIME LIMIT EXCEEDED | -- | 4 | details |
#34 | TIME LIMIT EXCEEDED | -- | 4 | details |
#35 | TIME LIMIT EXCEEDED | -- | 4 | details |
#36 | TIME LIMIT EXCEEDED | -- | 4 | details |
#37 | TIME LIMIT EXCEEDED | -- | 4 | details |
#38 | TIME LIMIT EXCEEDED | -- | 4 | details |
#39 | TIME LIMIT EXCEEDED | -- | 4 | details |
#40 | TIME LIMIT EXCEEDED | -- | 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 boolean[][] alkup; public static void main(String[] args) { boolean debug = false; // debug = true; Scanner s = new Scanner(System.in); t = new boolean[8][8]; alkup = new boolean[8][8]; //TreeSet<Ruutu> collisions = new TreeSet<>(); //int[][] collisions = new int[8][8]; for (int y=0; y<8; y++) { String line = s.next(); for (int x=0; x<8; x++) { if (line.charAt(x) == 'M') { t[y][x] = true; alkup[y][x] = true; } } } 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> parasTunnettu = null; ArrayList<String> siirrot = new ArrayList<>(); long timeAlussa = System.currentTimeMillis(); while (System.currentTimeMillis() - timeAlussa < 950) { if (score == 0) { if (debug) System.out.println("done, siirtoja=" + siirrot.size()); if (parasTunnettu == null || parasTunnettu.size() > siirrot.size()) { parasTunnettu = siirrot; } for (int y=0; y<8; y++) { for (int x=0; x<8; x++) { t[y][x] = alkup[y][x]; } } score = score(); siirrot = new ArrayList<>(); } 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 if (newScore == score && rng.nextInt(10) >= 1) { peruKaanto(y,x); } else { score = newScore; siirrot.add((x+1) + " " + (y+1)); } } System.out.println(parasTunnettu.size()); if (!debug) { for (String siirto : parasTunnettu) 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: TIME LIMIT EXCEEDED
input |
---|
VMMVVMVV MMVVMVVV MMVVMMMM MVVVMVVM MVVVVMVM ... |
correct output |
---|
100000 |
user output |
---|
(empty) |
Test 2
Group: 1
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVMVVMMV VVMMVVVV VMMVMMVM MVVVVMVM MVMVMMVM ... |
correct output |
---|
100000 |
user output |
---|
(empty) |
Test 3
Group: 1
Verdict: TIME LIMIT EXCEEDED
input |
---|
VMMMVMVV MMMVMVMV VMMVMVVM VVVMVMMV MVMVMVMV ... |
correct output |
---|
100000 |
user output |
---|
(empty) |
Test 4
Group: 1
Verdict: TIME LIMIT EXCEEDED
input |
---|
VVVMVMVV VMMVMVMM MVVMMVMV VMVMMVMM MMVVMMVM ... |
correct output |
---|
100000 |
user output |
---|
(empty) |
Test 5
Group: 1
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVMVVMMM VVMMVVMV MVVMVVMM VMVMVMMV MMVMVVVM ... |
correct output |
---|
100000 |
user output |
---|
(empty) |
Test 6
Group: 1
Verdict: TIME LIMIT EXCEEDED
input |
---|
VMMVMVVM VVMMVVMM MMMVMVVM VMMVMMVM MVMVMMMV ... |
correct output |
---|
100000 |
user output |
---|
(empty) |
Test 7
Group: 1
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVVVVMMM MMMMMMMM VVVVVMMV MMVVMVVM VMVVVVMV ... |
correct output |
---|
100000 |
user output |
---|
(empty) |
Test 8
Group: 1
Verdict: TIME LIMIT EXCEEDED
input |
---|
VMMVMVMM MMMVVMMM MVVVVVVV VVVVMMMV MVVVMVVM ... |
correct output |
---|
100000 |
user output |
---|
(empty) |
Test 9
Group: 1
Verdict: TIME LIMIT EXCEEDED
input |
---|
VVVVVMMM MMVVVVVV MVVVMMMM VVMVVVVM VMMVMVMM ... |
correct output |
---|
100000 |
user output |
---|
(empty) |
Test 10
Group: 1
Verdict: TIME LIMIT EXCEEDED
input |
---|
VMMVMMMM VVMVVVVV VMMVMVMV VMMVMVMM VVVMMMMM ... |
correct output |
---|
100000 |
user output |
---|
(empty) |
Test 11
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
VMVMVVMM MMVMVVMM VMVVVMMV VVVMVMVM VVMMVVMM ... |
correct output |
---|
25000 |
user output |
---|
(empty) |
Test 12
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVMVVMVV VMMVVMVM VMVVVMMM VMMMMVVM MMVVVMMM ... |
correct output |
---|
25000 |
user output |
---|
(empty) |
Test 13
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVVMMVVV MMVVMVMM VVVMVMVV VMVMMMMM MVVMMVMV ... |
correct output |
---|
25000 |
user output |
---|
(empty) |
Test 14
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
VVMMMVMV VMVVVMVV VVMVVVMM MVVMVMVM MMVVMMMM ... |
correct output |
---|
25000 |
user output |
---|
(empty) |
Test 15
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVVVMVVV MMMMVMMM MVMMMVVM MMVVVMVM VMVVVMMV ... |
correct output |
---|
25000 |
user output |
---|
(empty) |
Test 16
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
VMMVMVVM VMMVVVVV MVMVMMVM VMMVVVMV VVMVMMVM ... |
correct output |
---|
25000 |
user output |
---|
(empty) |
Test 17
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVVMMVVM MVVVMMMV MVVMMVVM VMMVMVMV VMMVMMMM ... |
correct output |
---|
25000 |
user output |
---|
(empty) |
Test 18
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVMMVVMM VVMMMMVV VMVVVVVM MVMMMVMV VMVVVMVM ... |
correct output |
---|
25000 |
user output |
---|
(empty) |
Test 19
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVVVVVVV VMMVMVVM VMVMMMMV MVMVMMMM MMVVVMMM ... |
correct output |
---|
25000 |
user output |
---|
(empty) |
Test 20
Group: 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVVVMMMM MMVMMVMV MVVVVVMM VVMMMVVM VVVMVMVV ... |
correct output |
---|
25000 |
user output |
---|
(empty) |
Test 21
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
VMVVMVMM MMMMVMMV VVVMVVVV MVMVMVVM VMMVMMMM ... |
correct output |
---|
5000 |
user output |
---|
(empty) |
Test 22
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
VVVVVVMM MMMVMMVV VVVVVVMV MMMVMVVV MVVMMMMV ... |
correct output |
---|
5000 |
user output |
---|
(empty) |
Test 23
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
MMVMVMVV MMVVMVVM VMMVVMVM MMMMMMVV MVVVVMVM ... |
correct output |
---|
5000 |
user output |
---|
(empty) |
Test 24
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVMVVMVM VVMVVMVM MMMMVMVV MVVMMVVV MMMMMVVV ... |
correct output |
---|
5000 |
user output |
---|
(empty) |
Test 25
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVVVMVVM MMMMVVMV VMMVMMVV VVMVMVMV MVMMMVMM ... |
correct output |
---|
5000 |
user output |
---|
(empty) |
Test 26
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
VMVMVVVM MMMVVVMM MMVVVVVM VVVVMMVV VMMVVMMV ... |
correct output |
---|
5000 |
user output |
---|
(empty) |
Test 27
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
MMVMMVVM MVVVMVMV MVVVMVVM VMVMMMVV VMMVVVVV ... |
correct output |
---|
5000 |
user output |
---|
(empty) |
Test 28
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVMMVMMV VMVMMMVV MMMMVVMV VVVVMMMM MMMVMMVV ... |
correct output |
---|
5000 |
user output |
---|
(empty) |
Test 29
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
VVVVMVMV MMMVVMVM MVVVMVMV VVVMVVMM VMMMMMVV ... |
correct output |
---|
5000 |
user output |
---|
(empty) |
Test 30
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVVVMVVV MMVVMMMM MVVVVVVV MVMVMMMV VMMMVMMM ... |
correct output |
---|
5000 |
user output |
---|
(empty) |
Test 31
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVMMVMMV VVVMMVVV VMMVVMMV VVMMMVVM VVVMMMVV ... |
correct output |
---|
250 |
user output |
---|
(empty) |
Test 32
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
VVMMVVVM VMVVMMVV VMMMMMMV VVMVMVVV VMMVMVMM ... |
correct output |
---|
250 |
user output |
---|
(empty) |
Test 33
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
MMVVMVMV VVVMVMMM VVVVMVMM MVVMVVMV VMMVMVVM ... |
correct output |
---|
250 |
user output |
---|
(empty) |
Test 34
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
VMVMVVMV MVVMMMMM MMVVMMMM VMVMVVVM VMMMVVVM ... |
correct output |
---|
250 |
user output |
---|
(empty) |
Test 35
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
VMVMVMMM VMMVVVMM MMVMVMMM MVMMVVVV VMMVMMMV ... |
correct output |
---|
250 |
user output |
---|
(empty) |
Test 36
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
MVMVMVMM MVMVMMMV MMVVVVMM MVMVVVVV VMMMVVMM ... |
correct output |
---|
250 |
user output |
---|
(empty) |
Test 37
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
VMMMMVMM VVMMMVMV VMVVVVVV MVMMMVVM VMVMMVVM ... |
correct output |
---|
250 |
user output |
---|
(empty) |
Test 38
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
VMMVMVMV VVMVMVMM MMMVMVMM MVVVVMMM MMVVVMVV ... |
correct output |
---|
250 |
user output |
---|
(empty) |
Test 39
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
MMMMMVMV MVVMMMMV VMVVVVMM VMVVVMMV MVMMMVMM ... |
correct output |
---|
250 |
user output |
---|
(empty) |
Test 40
Group: 4
Verdict: TIME LIMIT EXCEEDED
input |
---|
VMMMMMMV VMMVVVVV MVMMVMMV MVVVVMMV MVVVVMMM ... |
correct output |
---|
250 |
user output |
---|
(empty) |