Code Submission Evaluation System Login

Datatähti 2019 alku

Start:2018-10-01 00:00:00
End:2018-10-15 00:00:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - Datatähti 2019 alku - Results
History
2018-10-14 09:07:2945
2018-10-14 00:21:5645
2018-10-14 00:20:450
2018-10-14 00:15:1414
2018-10-13 23:53:590
2018-10-13 23:52:430
2018-10-09 10:13:0831
2018-10-09 10:11:4031
2018-10-07 08:46:2431
2018-10-07 08:28:1931
2018-10-07 08:27:320
2018-10-07 08:08:0731
2018-10-06 14:35:160
2018-10-06 14:30:450
2018-10-06 14:28:020
2018-10-06 14:21:310
2018-10-06 11:53:090
2018-10-06 11:35:330
2018-10-06 11:25:280
2018-10-06 11:19:280
2018-10-06 11:01:060
2018-10-05 21:39:300
2018-10-05 21:22:500
Task:Ruudukko
Sender:Jaahas
Submission time:2018-10-14 09:07:29
Language:Java
Status:READY
Score:45

Feedback

groupverdictscore
#1ACCEPTED31
#2ACCEPTED14
#3TIME LIMIT EXCEEDED0

Test results

testverdicttime (s)group
#1ACCEPTED0.14 / 1.001details
#2ACCEPTED0.15 / 1.001details
#3ACCEPTED0.14 / 1.001details
#4ACCEPTED0.14 / 1.001details
#5ACCEPTED0.15 / 1.001details
#6ACCEPTED0.14 / 1.001details
#7ACCEPTED0.14 / 1.001details
#8ACCEPTED0.14 / 1.001details
#9ACCEPTED0.14 / 1.001details
#10ACCEPTED0.15 / 1.001details
#11ACCEPTED0.14 / 1.002details
#12ACCEPTED0.14 / 1.002details
#13ACCEPTED0.14 / 1.002details
#14ACCEPTED0.16 / 1.002details
#15ACCEPTED0.19 / 1.002details
#16ACCEPTED0.20 / 1.002details
#17ACCEPTED0.19 / 1.002details
#18ACCEPTED0.20 / 1.002details
#19ACCEPTED0.20 / 1.002details
#20ACCEPTED0.20 / 1.002details
#21TIME LIMIT EXCEEDED-- / 1.003details
#22TIME LIMIT EXCEEDED-- / 1.003details
#23TIME LIMIT EXCEEDED-- / 1.003details
#24TIME LIMIT EXCEEDED-- / 1.003details
#25ACCEPTED0.21 / 1.003details
#26TIME LIMIT EXCEEDED-- / 1.003details
#27TIME LIMIT EXCEEDED-- / 1.003details
#28TIME LIMIT EXCEEDED-- / 1.003details
#29ACCEPTED0.24 / 1.003details
#30ACCEPTED0.20 / 1.003details

Code

//package com.tuomas;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Ruudukko {
    static int c = 0;
    static int n = 0;
    static char[][] ruudukko;
    static char[][] ruudukko2;
    static boolean[] ai;
    static boolean[] aj;
    static boolean[] bi;
    static boolean[] bj;
    static final long MOD = 1000000007;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        n = Integer.parseInt(br.readLine());
        ruudukko = new char[n][n];
        ruudukko2 = new char[n][n];
        ai = new boolean[n];
        aj = new boolean[n];
        bi = new boolean[n];
        bj = new boolean[n];
        long count = 0;
        for (int i = 0; i < n; i++) {
            String string = br.readLine();
            for (int j = 0; j < n; j++) {
                ruudukko[i][j] = string.charAt(j);
                if(ruudukko[i][j] == 'A') {
                    count++;
                    ai[i] = true;
                    aj[j] = true;
                } else if(ruudukko[i][j] == 'B') {
                    count++;
                    bi[i] = true;
                    bj[j] = true;
                }
            }
        }
        if(count == 0) {
            long result = (factorial(n) * (n - 1)) % MOD;
            result = (result * f(n - 2)) % MOD;
            System.out.println(result);
        } else {
            hakua(0);
            System.out.println(c);
        }

    }

    static void hakua(int i) {
        if(i >= n) {
            hakub(0);
            return;
        } else if(ai[i]) {
            hakua(i + 1);
        } else {
            for (int j = 0; j < n; j++) {
                if(ruudukko[i][j] == '.') {
                    if(aj[j]) {
                        continue;
                    }
                    aj[j] = true;
                    ruudukko[i][j] = 'A';
                    hakua(i + 1);
                    aj[j] = false;
                    ruudukko[i][j] = '.';
                }
            }
        }
    }

    static void hakub(int i) {
        if(i >= n) {
            c = (c + 1) % (int)MOD;
            return;
        } else if(bi[i]) {
            hakub(i + 1);
        } else {
            for (int j = 0; j < n; j++) {
                if(ruudukko[i][j] == '.') {
                    if(bj[j]) {
                        continue;
                    }
                    bj[j] = true;
                    hakub(i + 1);
                    bj[j] = false;
                }
            }
        }
    }

    public static long factorial(int n) {
        long result = 1;

        for (long factor = 2; factor <= n; factor++) {
            result = (result * factor) % MOD;
        }

        return result;
    }

    public static long f(long n) {
        if (n <= 1) {
            return 1;
        } else {
            long r1 = 1;
            long r2 = 1;
            for(long i = 2; i <= n; i++) {
                long temp = r2;
                r2 = ((r2 * i)%MOD + (r1 * (i-1))%MOD)%MOD;
                r1 = temp;
            }
            return r2;
        }
    }
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
2
..
..
view   save

correct output
2
view   save

user output
2
view   save

Test 2

Group: 1

Verdict: ACCEPTED

input
2
..
A.
view   save

correct output
1
view   save

user output
1
view   save

Test 3

Group: 1

Verdict: ACCEPTED

input
2
B.
.A
view   save

correct output
0
view   save

user output
0
view   save

Test 4

Group: 1

Verdict: ACCEPTED

input
3
...
...
...
view   save

correct output
12
view   save

user output
12
view   save

Test 5

Group: 1

Verdict: ACCEPTED

input
4
....
....
....
....
view   save

correct output
216
view   save

user output
216
view   save

Test 6

Group: 1

Verdict: ACCEPTED

input
5
.....
.....
.....
.....
.....
view   save

correct output
5280
view   save

user output
5280
view   save

Test 7

Group: 1

Verdict: ACCEPTED

input
5
....A
.....
.....
.....
A....
view   save

correct output
264
view   save

user output
264
view   save

Test 8

Group: 1

Verdict: ACCEPTED

input
5
B....
.....
.....
.A.B.
.B...
view   save

correct output
22
view   save

user output
22
view   save

Test 9

Group: 1

Verdict: ACCEPTED

input
5
B.A..
....A
.....
A.B..
....B
view   save

correct output
2
view   save

user output
2
view   save

Test 10

Group: 1

Verdict: ACCEPTED

input
5
A.B..
BA...
.B.A.
...BA
....B
view   save

correct output
1
view   save

user output
1
view   save

Test 11

Group: 2

Verdict: ACCEPTED

input
10
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
view   save

correct output
306442892
view   save

user output
306442892
view   save

Test 12

Group: 2

Verdict: ACCEPTED

input
50
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
...
view   save

correct output
694861480
view   save

user output
694861480
view   save

Test 13

Group: 2

Verdict: ACCEPTED

input
111
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
view   save

correct output
555319110
view   save

user output
555319110
view   save

Test 14

Group: 2

Verdict: ACCEPTED

input
222
.................................
.................................
.................................
.................................
.................................
view   save

correct output
108372237
view   save

user output
108372237
view   save

Test 15

Group: 2

Verdict: ACCEPTED

input
333
.................................
.................................
.................................
view   save

correct output
259107857
view   save

user output
259107857
view   save

Test 16

Group: 2

Verdict: ACCEPTED

input
444
.................................
.................................
.................................
view   save

correct output
19906314
view   save

user output
19906314
view   save

Test 17

Group: 2

Verdict: ACCEPTED

input
497
.................................
.................................
view   save

correct output
224313667
view   save

user output
224313667
view   save

Test 18

Group: 2

Verdict: ACCEPTED

input
498
.................................
.................................
view   save

correct output
929574601
view   save

user output
929574601
view   save

Test 19

Group: 2

Verdict: ACCEPTED

input
499
.................................
.................................
view   save

correct output
600226043
view   save

user output
600226043
view   save

Test 20

Group: 2

Verdict: ACCEPTED

input
500
.................................
.................................
view   save

correct output
198353194
view   save

user output
198353194
view   save

Test 21

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
499
.................................
.........................A.......
view   save

correct output
840243733
view   save

user output
(no output)
view   save

Test 22

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
499
........................A........
..........A...B..................
view   save

correct output
4146290
view   save

user output
(no output)
view   save

Test 23

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
499
B.........A......................
....AB...........................
view   save

correct output
173518884
view   save

user output
(no output)
view   save

Test 24

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
499
...A....B........................
.........A...B...................
view   save

correct output
20044800
view   save

user output
(no output)
view   save

Test 25

Group: 3

Verdict: ACCEPTED

input
499
AB...............................
....B.......A....................
view   save

correct output
2
view   save

user output
2
view   save

Test 26

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
500
.................................
.................................
view   save

correct output
121064146
view   save

user output
(no output)
view   save

Test 27

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
500
.................................
..................A..............
view   save

correct output
848435259
view   save

user output
(no output)
view   save

Test 28

Group: 3

Verdict: TIME LIMIT EXCEEDED

input
500
.....B........A..................
..........B...............A......
view   save

correct output
296240911
view   save

user output
(no output)
view   save

Test 29

Group: 3

Verdict: ACCEPTED

input
500
.A......B........................
..A.............B................
view   save

correct output
2196
view   save

user output
2196
view   save

Test 30

Group: 3

Verdict: ACCEPTED

input
500
...AB............................
.A.....B.........................
view   save

correct output
1
view   save

user output
1
view   save