Submission #781506

# Submission time Handle Problem Language Result Execution time Memory
781506 2023-07-13T07:06:29 Z 이성호(#10012) None (JOI16_solitaire) C++17
0 / 100
16 ms 468 KB
#include <iostream>
using namespace std;
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];
        }
    }
    cout << dp[(1 << pv) - 1] << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Incorrect 16 ms 432 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 432 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 3 ms 212 KB Output is correct
2 Incorrect 16 ms 432 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Incorrect 16 ms 432 KB Output isn't correct
3 Halted 0 ms 0 KB -