# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
313793 | jhnah917 | Amusement Park (CEOI19_amusementpark) | C++14 | 2557 ms | 2844 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
const int mod = 998244353;
int n, m;
bool g[22][22], chk[1<<18];
ll dp[1<<18];
int main(){
ios_base::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> m;
for(int i=0; i<m; i++){
int s, e; cin >> s >> e; s--; e--;
g[s][e] = g[e][s] = 1;
}
for(int i=0; i<(1<<n); i++){
for(int j=0; j<n; j++) if(i & (1 << j)) {
for(int k=j+1; k<n; k++) if(i & (1 << k)) {
if(g[j][k]){ chk[i] = 1; break; }
}
if(chk[i]) break;
}
}
dp[0] = 1;
for(int i=1; i<(1<<n); i++){
for(int j=i; j; j=(i&(j-1))) if(!chk[j]) {
if(__builtin_popcount(j) & 1) dp[i] += dp[i^j];
else dp[i] = dp[i] -= dp[i^j];
if(dp[i] < 0) dp[i] += mod;
if(dp[i] >= mod) dp[i] %= mod;
}
}
cout << dp[(1<<n)-1] * m % mod * (mod/2+1) % mod;
}
컴파일 시 표준 에러 (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... |