Submission #991811

# Submission time Handle Problem Language Result Execution time Memory
991811 2024-06-03T07:47:15 Z vjudge1 Amusement Park (CEOI19_amusementpark) C++17
0 / 100
1 ms 396 KB
#include<bits/stdc++.h>
using namespace std;
int has[18][18],indep[1<<18];
long long dp[1<<18],mod=998244353;
long long ans;
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        has[x][y]=1;
        has[y][x]=1;
    }
    for(int i=0;i<1<<n;i++){
        vector<int>v;
        for(int j=0;j<n;j++)
            if(i&1<<j)
                v.push_back(j);
        for(int j=0;j<v.size();j++)
            for(int k=j+1;k<v.size();k++)
                indep[i]|=has[j][k];
        indep[i]^=1;
    }
    dp[0]=1;
    for(int i=1;i<1<<n;i++)
        for(int j=i-1&i;;j=j-1&i){
            int cnt=__builtin_popcount(i^j);
            dp[i]=(dp[i]+mod+indep[i-j]*dp[j]*(cnt%2*2-1))%mod;
            if(!j) break;
        }
    cout<<(mod+1)/2*dp[(1<<n)-1]%mod*m%mod;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for(int j=0;j<v.size();j++)
      |                     ~^~~~~~~~~
amusementpark.cpp:22:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             for(int k=j+1;k<v.size();k++)
      |                           ~^~~~~~~~~
amusementpark.cpp:28:20: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   28 |         for(int j=i-1&i;;j=j-1&i){
      |                   ~^~
amusementpark.cpp:28:29: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   28 |         for(int j=i-1&i;;j=j-1&i){
      |                            ~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 396 KB Output isn't correct
4 Halted 0 ms 0 KB -