# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
208155 | 2020-03-10T06:32:52 Z | E869120 | Amusement Park (CEOI19_amusementpark) | C++14 | 5 ms | 376 KB |
#include <iostream> #include <algorithm> #include <vector> using namespace std; #pragma warning (disable: 4996) int mod = 998244353; int N, M, A[1009], B[1009]; int dp[15000000], power3[19]; vector<int> X[1009]; int main() { cin >> N >> M; for (int i = 1; i <= M; i++) { cin >> A[i] >> B[i]; A[i]--; B[i]--; } for (int i = 1; i <= M; i++) { X[A[i]].push_back(B[i]); X[B[i]].push_back(A[i]); } power3[0] = 1; for (int i = 1; i <= N; i++) power3[i] = 3LL * power3[i - 1]; for (int i = 0; i < N; i++) { int ret = 2 * power3[i]; for (int j = i + 1; j < N; j++) ret += power3[j]; for (int j : X[i]) { if (j < i) ret += power3[j]; } dp[ret] = 1; } for (int i = 0; i < power3[N]; i++) { if (dp[i] == 0) continue; int col[15]; for (int j = 0; j < N; j++) col[j] = (i / power3[j]) % 3; for (int j = 0; j < N; j++) { if (col[j] != 1) continue; int ret = i + power3[j]; for (int k = 0; k < j; k++) { if (col[k] == 0) ret -= power3[k]; } for (int k : X[j]) { if ((col[k] == 0 && k < j) || col[k] == 1) ret += power3[k]; } dp[ret] += dp[i]; if (dp[ret] >= mod) dp[ret] -= mod; } } long long val = dp[power3[N] - 1]; val *= M; val %= mod; if (val % 2 == 1) val += mod; val /= 2LL; cout << val << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Incorrect | 5 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Incorrect | 5 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Incorrect | 5 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Incorrect | 5 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Incorrect | 5 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |