# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
53278 | 2018-06-29T06:58:39 Z | ainta | Solitaire (JOI16_solitaire) | C++17 | 371 ms | 1688 KB |
#include<cstdio> #include<algorithm> using namespace std; int n, w[2010][5], C[2010]; int cnt; long long D[6010][2], dd, Mod = 1000000007, TD[6010][2]; char q[2010]; int main() { int i, j; scanf("%d", &n); for (i = 1; i <= 3; i++) { scanf("%s", q + 1); for (j = 1; j <= n; j++) { if (q[j] == 'o')w[j][i] = 1; } } for (i = 0; i <= n; i++) { for (j = 0; j <= 3; j++) { if (w[i][j] + w[i + 1][j] + w[i][j + 1] + w[i + 1][j + 1] == 0) { puts("0"); return 0; } } } dd = 1; for (i = 1; i <= n; i++) { for (j = 1; j <= 3; j++)if (!w[i][j])C[i] += (1 << (j - 1)); } for (i = 1; i <= n; i++) { if (!(C[i-1]&2)) { if (C[i] == 7) { cnt += 3; for (j = 1; j <= cnt; j++) { int c1 = (j - 1)*(j - 2); int c2 = (cnt - 1)*(cnt - 2) - c1; D[j][0] = dd*c1 % Mod; D[j][1] = dd*c2 % Mod; } } if (C[i] == 5) { cnt += 2; dd = cnt*(cnt - 1)*dd%Mod; } if (C[i] == 1 || C[i] == 4) { cnt++; dd = dd*cnt%Mod; } if (C[i] == 3 || C[i] == 6) { cnt+=2; for (j = 1; j <= cnt; j++) { D[j][0] = dd*(j - 1) % Mod; D[j][1] = dd*(cnt - j) % Mod; } } if (C[i] == 2) { cnt++; for (j = 1; j <= cnt; j++)D[j][0] = dd, D[j][1] = 0; } continue; } long long s1 = 0, s2 = 0; for (j = 1; j <= cnt; j++) { s1 = (s1 + D[j][0]) % Mod; s2 = (s2 + D[j][1]) % Mod; } if (C[i] == 0) { dd = (s1+s2) % Mod; continue; } if (C[i] == 1 || C[i] == 4) { cnt++; dd = (s1+s2) * cnt % Mod; continue; } if (C[i] == 5) { cnt += 2; dd = (s1+s2)*cnt*(cnt - 1) % Mod; continue; } for (j = 0; j <= cnt + 3; j++)TD[j][0] = TD[j][1] = 0; if (C[i] == 2) { long long s = 0; for (j = cnt; j >= 1; j--) { s = (s+D[j][1])%Mod; TD[j][0] += s; } cnt++; for (j = 1; j <= cnt; j++) { TD[j][0] += s1; } } if (C[i] == 3 || C[i] == 6) { long long s = 0; for (j = cnt+1; j >= 2; j--) { s = (s + D[j-1][1]) % Mod; TD[j][0] += s*(j-1); } s = 0; for (j = 1; j <= cnt; j++) { s = (s + D[j][0]) % Mod; TD[j+1][1] += s*(cnt - j + 1); } cnt += 2; s = 0; for (j = cnt - 1; j >= 2; j--) { s = (s + D[j - 1][0]) % Mod; TD[j][0] += s*(j - 1); } s = 0; for (j = 3; j <= cnt; j++) { s = (s + D[j - 2][0]) % Mod; TD[j][0] += s*(j - 1); } } if (C[i] == 7) { cnt += 3; long long s = 0; for (j = 3; j <= cnt; j++) { s = (s + D[j - 2][0]) % Mod; TD[j][0] += (j - 1)*(j - 2)*s1; TD[j][1] += (j - 1)*(cnt - j)*s*2; } s = 0; for (j = 2; j <= cnt-2; j++) { s = (s + D[j - 1][0]) % Mod; TD[j][1] += s*(cnt - j)*(cnt - j - 1); } } for (j = 1; j <= cnt; j++) { D[j][0] = TD[j][0]%Mod; D[j][1] = TD[j][1]%Mod; } } if (w[n][2])printf("%lld\n", dd%Mod); else { long long res = 0; for (i = 1; i <= cnt; i++)res = (res + D[i][0]) % Mod; printf("%lld\n", res); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 360 KB | Output is correct |
3 | Correct | 2 ms | 472 KB | Output is correct |
4 | Correct | 2 ms | 496 KB | Output is correct |
5 | Correct | 2 ms | 528 KB | Output is correct |
6 | Correct | 2 ms | 624 KB | Output is correct |
7 | Correct | 2 ms | 728 KB | Output is correct |
8 | Correct | 2 ms | 728 KB | Output is correct |
9 | Correct | 2 ms | 760 KB | Output is correct |
10 | Correct | 2 ms | 760 KB | Output is correct |
11 | Correct | 2 ms | 760 KB | Output is correct |
12 | Correct | 2 ms | 760 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 776 KB | Output is correct |
2 | Correct | 49 ms | 780 KB | Output is correct |
3 | Correct | 9 ms | 916 KB | Output is correct |
4 | Correct | 99 ms | 916 KB | Output is correct |
5 | Correct | 101 ms | 916 KB | Output is correct |
6 | Correct | 81 ms | 916 KB | Output is correct |
7 | Correct | 31 ms | 916 KB | Output is correct |
8 | Correct | 96 ms | 1044 KB | Output is correct |
9 | Correct | 104 ms | 1044 KB | Output is correct |
10 | Correct | 28 ms | 1044 KB | Output is correct |
11 | Correct | 55 ms | 1048 KB | Output is correct |
12 | Correct | 102 ms | 1048 KB | Output is correct |
13 | Correct | 138 ms | 1060 KB | Output is correct |
14 | Correct | 157 ms | 1068 KB | Output is correct |
15 | Correct | 147 ms | 1076 KB | Output is correct |
16 | Correct | 139 ms | 1236 KB | Output is correct |
17 | Correct | 142 ms | 1236 KB | Output is correct |
18 | Correct | 138 ms | 1236 KB | Output is correct |
19 | Correct | 139 ms | 1236 KB | Output is correct |
20 | Correct | 139 ms | 1236 KB | Output is correct |
21 | Correct | 138 ms | 1236 KB | Output is correct |
22 | Correct | 145 ms | 1236 KB | Output is correct |
23 | Correct | 135 ms | 1236 KB | Output is correct |
24 | Correct | 134 ms | 1236 KB | Output is correct |
25 | Correct | 134 ms | 1236 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1236 KB | Output is correct |
2 | Correct | 2 ms | 1236 KB | Output is correct |
3 | Correct | 2 ms | 1236 KB | Output is correct |
4 | Correct | 2 ms | 1236 KB | Output is correct |
5 | Correct | 2 ms | 1236 KB | Output is correct |
6 | Correct | 2 ms | 1236 KB | Output is correct |
7 | Correct | 3 ms | 1236 KB | Output is correct |
8 | Correct | 2 ms | 1236 KB | Output is correct |
9 | Correct | 2 ms | 1236 KB | Output is correct |
10 | Correct | 2 ms | 1236 KB | Output is correct |
11 | Correct | 2 ms | 1236 KB | Output is correct |
12 | Correct | 2 ms | 1236 KB | Output is correct |
13 | Correct | 2 ms | 1236 KB | Output is correct |
14 | Correct | 3 ms | 1236 KB | Output is correct |
15 | Correct | 2 ms | 1236 KB | Output is correct |
16 | Correct | 2 ms | 1236 KB | Output is correct |
17 | Correct | 2 ms | 1236 KB | Output is correct |
18 | Correct | 2 ms | 1236 KB | Output is correct |
19 | Correct | 2 ms | 1236 KB | Output is correct |
20 | Correct | 2 ms | 1236 KB | Output is correct |
21 | Correct | 2 ms | 1236 KB | Output is correct |
22 | Correct | 3 ms | 1236 KB | Output is correct |
23 | Correct | 2 ms | 1236 KB | Output is correct |
24 | Correct | 3 ms | 1236 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 360 KB | Output is correct |
3 | Correct | 2 ms | 472 KB | Output is correct |
4 | Correct | 2 ms | 496 KB | Output is correct |
5 | Correct | 2 ms | 528 KB | Output is correct |
6 | Correct | 2 ms | 624 KB | Output is correct |
7 | Correct | 2 ms | 728 KB | Output is correct |
8 | Correct | 2 ms | 728 KB | Output is correct |
9 | Correct | 2 ms | 760 KB | Output is correct |
10 | Correct | 2 ms | 760 KB | Output is correct |
11 | Correct | 2 ms | 760 KB | Output is correct |
12 | Correct | 2 ms | 760 KB | Output is correct |
13 | Correct | 2 ms | 1236 KB | Output is correct |
14 | Correct | 2 ms | 1236 KB | Output is correct |
15 | Correct | 2 ms | 1236 KB | Output is correct |
16 | Correct | 2 ms | 1236 KB | Output is correct |
17 | Correct | 2 ms | 1236 KB | Output is correct |
18 | Correct | 2 ms | 1236 KB | Output is correct |
19 | Correct | 3 ms | 1236 KB | Output is correct |
20 | Correct | 2 ms | 1236 KB | Output is correct |
21 | Correct | 2 ms | 1236 KB | Output is correct |
22 | Correct | 2 ms | 1236 KB | Output is correct |
23 | Correct | 2 ms | 1236 KB | Output is correct |
24 | Correct | 2 ms | 1236 KB | Output is correct |
25 | Correct | 2 ms | 1236 KB | Output is correct |
26 | Correct | 3 ms | 1236 KB | Output is correct |
27 | Correct | 2 ms | 1236 KB | Output is correct |
28 | Correct | 2 ms | 1236 KB | Output is correct |
29 | Correct | 2 ms | 1236 KB | Output is correct |
30 | Correct | 2 ms | 1236 KB | Output is correct |
31 | Correct | 2 ms | 1236 KB | Output is correct |
32 | Correct | 2 ms | 1236 KB | Output is correct |
33 | Correct | 2 ms | 1236 KB | Output is correct |
34 | Correct | 3 ms | 1236 KB | Output is correct |
35 | Correct | 2 ms | 1236 KB | Output is correct |
36 | Correct | 3 ms | 1236 KB | Output is correct |
37 | Correct | 2 ms | 1236 KB | Output is correct |
38 | Correct | 3 ms | 1236 KB | Output is correct |
39 | Correct | 2 ms | 1236 KB | Output is correct |
40 | Correct | 6 ms | 1236 KB | Output is correct |
41 | Correct | 3 ms | 1236 KB | Output is correct |
42 | Correct | 4 ms | 1236 KB | Output is correct |
43 | Correct | 6 ms | 1236 KB | Output is correct |
44 | Correct | 3 ms | 1236 KB | Output is correct |
45 | Correct | 5 ms | 1300 KB | Output is correct |
46 | Correct | 3 ms | 1300 KB | Output is correct |
47 | Correct | 4 ms | 1300 KB | Output is correct |
48 | Correct | 6 ms | 1300 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 360 KB | Output is correct |
3 | Correct | 2 ms | 472 KB | Output is correct |
4 | Correct | 2 ms | 496 KB | Output is correct |
5 | Correct | 2 ms | 528 KB | Output is correct |
6 | Correct | 2 ms | 624 KB | Output is correct |
7 | Correct | 2 ms | 728 KB | Output is correct |
8 | Correct | 2 ms | 728 KB | Output is correct |
9 | Correct | 2 ms | 760 KB | Output is correct |
10 | Correct | 2 ms | 760 KB | Output is correct |
11 | Correct | 2 ms | 760 KB | Output is correct |
12 | Correct | 2 ms | 760 KB | Output is correct |
13 | Correct | 17 ms | 776 KB | Output is correct |
14 | Correct | 49 ms | 780 KB | Output is correct |
15 | Correct | 9 ms | 916 KB | Output is correct |
16 | Correct | 99 ms | 916 KB | Output is correct |
17 | Correct | 101 ms | 916 KB | Output is correct |
18 | Correct | 81 ms | 916 KB | Output is correct |
19 | Correct | 31 ms | 916 KB | Output is correct |
20 | Correct | 96 ms | 1044 KB | Output is correct |
21 | Correct | 104 ms | 1044 KB | Output is correct |
22 | Correct | 28 ms | 1044 KB | Output is correct |
23 | Correct | 55 ms | 1048 KB | Output is correct |
24 | Correct | 102 ms | 1048 KB | Output is correct |
25 | Correct | 138 ms | 1060 KB | Output is correct |
26 | Correct | 157 ms | 1068 KB | Output is correct |
27 | Correct | 147 ms | 1076 KB | Output is correct |
28 | Correct | 139 ms | 1236 KB | Output is correct |
29 | Correct | 142 ms | 1236 KB | Output is correct |
30 | Correct | 138 ms | 1236 KB | Output is correct |
31 | Correct | 139 ms | 1236 KB | Output is correct |
32 | Correct | 139 ms | 1236 KB | Output is correct |
33 | Correct | 138 ms | 1236 KB | Output is correct |
34 | Correct | 145 ms | 1236 KB | Output is correct |
35 | Correct | 135 ms | 1236 KB | Output is correct |
36 | Correct | 134 ms | 1236 KB | Output is correct |
37 | Correct | 134 ms | 1236 KB | Output is correct |
38 | Correct | 2 ms | 1236 KB | Output is correct |
39 | Correct | 2 ms | 1236 KB | Output is correct |
40 | Correct | 2 ms | 1236 KB | Output is correct |
41 | Correct | 2 ms | 1236 KB | Output is correct |
42 | Correct | 2 ms | 1236 KB | Output is correct |
43 | Correct | 2 ms | 1236 KB | Output is correct |
44 | Correct | 3 ms | 1236 KB | Output is correct |
45 | Correct | 2 ms | 1236 KB | Output is correct |
46 | Correct | 2 ms | 1236 KB | Output is correct |
47 | Correct | 2 ms | 1236 KB | Output is correct |
48 | Correct | 2 ms | 1236 KB | Output is correct |
49 | Correct | 2 ms | 1236 KB | Output is correct |
50 | Correct | 2 ms | 1236 KB | Output is correct |
51 | Correct | 3 ms | 1236 KB | Output is correct |
52 | Correct | 2 ms | 1236 KB | Output is correct |
53 | Correct | 2 ms | 1236 KB | Output is correct |
54 | Correct | 2 ms | 1236 KB | Output is correct |
55 | Correct | 2 ms | 1236 KB | Output is correct |
56 | Correct | 2 ms | 1236 KB | Output is correct |
57 | Correct | 2 ms | 1236 KB | Output is correct |
58 | Correct | 2 ms | 1236 KB | Output is correct |
59 | Correct | 3 ms | 1236 KB | Output is correct |
60 | Correct | 2 ms | 1236 KB | Output is correct |
61 | Correct | 3 ms | 1236 KB | Output is correct |
62 | Correct | 2 ms | 1236 KB | Output is correct |
63 | Correct | 3 ms | 1236 KB | Output is correct |
64 | Correct | 2 ms | 1236 KB | Output is correct |
65 | Correct | 6 ms | 1236 KB | Output is correct |
66 | Correct | 3 ms | 1236 KB | Output is correct |
67 | Correct | 4 ms | 1236 KB | Output is correct |
68 | Correct | 6 ms | 1236 KB | Output is correct |
69 | Correct | 3 ms | 1236 KB | Output is correct |
70 | Correct | 5 ms | 1300 KB | Output is correct |
71 | Correct | 3 ms | 1300 KB | Output is correct |
72 | Correct | 4 ms | 1300 KB | Output is correct |
73 | Correct | 6 ms | 1300 KB | Output is correct |
74 | Correct | 74 ms | 1300 KB | Output is correct |
75 | Correct | 19 ms | 1300 KB | Output is correct |
76 | Correct | 25 ms | 1300 KB | Output is correct |
77 | Correct | 137 ms | 1396 KB | Output is correct |
78 | Correct | 150 ms | 1396 KB | Output is correct |
79 | Correct | 52 ms | 1396 KB | Output is correct |
80 | Correct | 133 ms | 1396 KB | Output is correct |
81 | Correct | 102 ms | 1396 KB | Output is correct |
82 | Correct | 140 ms | 1404 KB | Output is correct |
83 | Correct | 54 ms | 1404 KB | Output is correct |
84 | Correct | 41 ms | 1420 KB | Output is correct |
85 | Correct | 103 ms | 1420 KB | Output is correct |
86 | Correct | 356 ms | 1528 KB | Output is correct |
87 | Correct | 325 ms | 1528 KB | Output is correct |
88 | Correct | 337 ms | 1580 KB | Output is correct |
89 | Correct | 371 ms | 1588 KB | Output is correct |
90 | Correct | 330 ms | 1588 KB | Output is correct |
91 | Correct | 347 ms | 1648 KB | Output is correct |
92 | Correct | 336 ms | 1648 KB | Output is correct |
93 | Correct | 367 ms | 1648 KB | Output is correct |
94 | Correct | 322 ms | 1648 KB | Output is correct |
95 | Correct | 327 ms | 1648 KB | Output is correct |
96 | Correct | 338 ms | 1648 KB | Output is correct |
97 | Correct | 356 ms | 1688 KB | Output is correct |