답안 #318032

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
318032 2020-10-31T09:31:00 Z neki Amusement Park (CEOI19_amusementpark) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
#define loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 100100
#define pa pair<ll, ll>
#define ld long double 
ll dp[1001000], kok[1000100];
vc<ll> ein[20], eout[20]; 
ll mod=998244353;
int main(){
    ll n, m;cin >> n >> m;
    loop(i, 0, m){
        ll a, b;cin >> a >> b;a--;b--;
        eout[a].ps(b);
        ein[b].ps(a);
    }
    loop(i, 1, 1<<n){
        vc<ll> act;
        loop(j, 0, n) if((1<<j) & i) act.ps(j);
        if(act.size()==1){
            kok[i]=1;
            continue;
        }
        fore(v, act){
            ll cur=0;
            fore(u, ein[v]) if(i & (1<<u)) cur++;
            dp[i]+=dp[i-(1<<v)] + cur * kok[i-(1<<v)]; dp[i]%=mod;
            kok[i]+=kok[i-(1<<v)]; kok[i]%=mod;
        }
    }
    cout << dp[(1<<n) - 1]<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -