답안 #608836

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
608836 2022-07-27T10:40:14 Z 1bin Amusement Park (CEOI19_amusementpark) C++14
0 / 100
8 ms 12628 KB
#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()
typedef long long ll;
const ll mod = 998244353;
ll n, m, a, b, e[18];
map<int, ll> dp[1 << 18];

int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a >> b; a--; b--;
        e[a] |= 1 << b;
        e[b] |= 1 << a;
    }
    dp[0][(1 << n) - 1] = 1;
    for(int a = 0; a < 1 << n; a++)
        for(auto& [b, x] : dp[a]){
            for(int i = 0; i < n; i++){
                if(!(b & (1 << i))) continue;
                int nxa = a | (1 << i);
                int nxb = (b ^ (1 << i)) | (e[i] & ((1 << n) - 1 - nxa));
                dp[nxa][nxb] += x; dp[nxa][nxb] %= mod;
            }
        }
    cout << dp[(1 << n) - 1][0] * m % mod * (mod + 1) / 2 % mod;
    return 0;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:22:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   22 |         for(auto& [b, x] : dp[a]){
      |                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12500 KB Output is correct
2 Correct 6 ms 12628 KB Output is correct
3 Incorrect 8 ms 12568 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12500 KB Output is correct
2 Correct 6 ms 12628 KB Output is correct
3 Incorrect 8 ms 12568 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12500 KB Output is correct
2 Correct 6 ms 12628 KB Output is correct
3 Incorrect 8 ms 12568 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12500 KB Output is correct
2 Correct 6 ms 12628 KB Output is correct
3 Incorrect 8 ms 12568 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 12500 KB Output is correct
2 Correct 6 ms 12628 KB Output is correct
3 Incorrect 8 ms 12568 KB Output isn't correct
4 Halted 0 ms 0 KB -