Submission #1066680

# Submission time Handle Problem Language Result Execution time Memory
1066680 2024-08-20T04:52:23 Z vjudge1 Amusement Park (CEOI19_amusementpark) C++17
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bitset<1<<20>indep;
ll dp[1<<20];
const ll mod=998244353;
int EDG[20][20];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        EDG[a][b]=1;
    }
    for(int i=1;i<1<<n;i++){
        vector<int>v;
        for(int j=0;j<n;j++)
            if(i&1<<j)
                v.push_back(j+1);
        int bad=0;
        for(auto i:v)
            for(auto j:v)
                if(EDG[i][j])
                    bad=1;
        indep[i]=!bad;
    }
    dp[0]=1;
    for(int i=1;i<1<<n;i++)
        for(int j=i;j;j=j-1&i)if(!indep[j]){
            int cnt=__builtin_popcount(j);
            dp[i]=(dp[i]+dp[i^j]*(cnt&1?1:-1))%mod;
        }
    cout<<dp[(1<<n)-1]*m%mod*499122177ll%mod<<'\n';
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:30:26: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   30 |         for(int j=i;j;j=j-1&i)if(!indep[j]){
      |                         ~^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -