# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
781507 |
2023-07-13T07:07:09 Z |
이성호(#10012) |
None (JOI16_solitaire) |
C++17 |
|
39 ms |
568 KB |
#include <iostream>
using namespace std;
const int mod = 1e9 + 7;
char c[2005][2005];
int N, dp[1<<16];
int pv = 0;
int x[16], y[16];
int main()
{
cin >> N;
for (int i = 0; i < N; i++) cin >> c[i];
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (c[i][j] == 'x') {
x[pv] = i;
y[pv++] = j;
}
}
}
dp[0] = 1;
for (int i = 0; i < (1 << pv) - 1; i++) {
for (int j = 0; j < pv; j++) {
if (i & (1 << j)) continue;
int cntx = 0, cnty = 0;
for (int k = 0; k < pv; k++) {
if (i & (1 << k)) continue;
if (x[j] == x[k] && abs(y[j] - y[k]) == 1) cntx++;
if (y[j] == y[k] && abs(x[j] - x[k]) == 1) cnty++;
}
if (cntx == 0 || cnty == 0) dp[i|(1<<j)] = (dp[i|(1<<j)] + dp[i]) % mod;
}
}
cout << dp[(1 << pv) - 1] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
16 ms |
444 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
37 ms |
444 KB |
Output is correct |
5 |
Correct |
38 ms |
544 KB |
Output is correct |
6 |
Correct |
39 ms |
564 KB |
Output is correct |
7 |
Correct |
36 ms |
468 KB |
Output is correct |
8 |
Correct |
35 ms |
468 KB |
Output is correct |
9 |
Correct |
35 ms |
568 KB |
Output is correct |
10 |
Correct |
36 ms |
548 KB |
Output is correct |
11 |
Correct |
34 ms |
564 KB |
Output is correct |
12 |
Correct |
35 ms |
556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
16 ms |
444 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
37 ms |
444 KB |
Output is correct |
5 |
Correct |
38 ms |
544 KB |
Output is correct |
6 |
Correct |
39 ms |
564 KB |
Output is correct |
7 |
Correct |
36 ms |
468 KB |
Output is correct |
8 |
Correct |
35 ms |
468 KB |
Output is correct |
9 |
Correct |
35 ms |
568 KB |
Output is correct |
10 |
Correct |
36 ms |
548 KB |
Output is correct |
11 |
Correct |
34 ms |
564 KB |
Output is correct |
12 |
Correct |
35 ms |
556 KB |
Output is correct |
13 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
16 ms |
444 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
37 ms |
444 KB |
Output is correct |
5 |
Correct |
38 ms |
544 KB |
Output is correct |
6 |
Correct |
39 ms |
564 KB |
Output is correct |
7 |
Correct |
36 ms |
468 KB |
Output is correct |
8 |
Correct |
35 ms |
468 KB |
Output is correct |
9 |
Correct |
35 ms |
568 KB |
Output is correct |
10 |
Correct |
36 ms |
548 KB |
Output is correct |
11 |
Correct |
34 ms |
564 KB |
Output is correct |
12 |
Correct |
35 ms |
556 KB |
Output is correct |
13 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |
14 |
Halted |
0 ms |
0 KB |
- |