# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
208161 | E869120 | Amusement Park (CEOI19_amusementpark) | C++14 | 2606 ms | 266744 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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[387420489], power3[19], col[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 val = 0;
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] - val;
for (int k : X[j]) { if ((col[k] == 1 && k < j) || col[k] == 0) ret += power3[k]; }
dp[ret] += dp[i]; val += power3[j];
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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |