# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
439172 | prvocislo | Amusement Park (CEOI19_amusementpark) | C++17 | 2870 ms | 308836 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 998244353; // staci ho pouzit len raz, na konci
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<int> e(n);
for (int i = 0, a, b; i < m; i++)
{
cin >> a >> b;
a--, b--;
e[a] |= (1 << b);
e[b] |= (1 << a);
}
vector<map<int, ll> > dp(1 << n); // dp[A][B]
dp[0][(1 << n) - 1] = 1;
for (int a = 0; a < (1 << n); a++)
{
for (const pair<int, ll> &i : dp[a])
{
int b = i.first; ll val = i.second;
for (int c = 0; c < n; c++)
{
if (!((1 << c)&b)) continue;
int nwa = a|(1 << c);
int bad = ((1 << (c + 1))-1)&b;
int in0 = e[c] & ((1 << n) - 1 - a);
int nwb = (b ^ bad) | in0;
dp[nwa][nwb] += dp[a][b];
}
}
}
cout << (dp[(1 << n) - 1][0] * (ll)m / 2ll) % mod << "\n";
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... |