Submission #1062615

#TimeUsernameProblemLanguageResultExecution timeMemory
106261512345678Amusement Park (CEOI19_amusementpark)C++17
19 / 100
106 ms10836 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int nx=11, mx=1e3+5, mod=998244353, mod2=1e9+7; ll n, m, a[mx], b[mx], res, pw[mx]; set<ll> s; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>m; pw[0]=1; for (int i=1; i<=m; i++) pw[i]=(pw[i-1]*2)%mod2; for (int i=1; i<=m; i++) cin>>a[i]>>b[i]; vector<int> v; for (int i=1; i<=n; i++) v.push_back(i); do { ll sm=0, cnt=0; for (int i=1; i<=m; i++) if (v[a[i]-1]>v[b[i]-1]) cnt++, sm=(sm+pw[i])%mod2; if (s.find(sm)==s.end()) res=(res+cnt)%mod, s.insert(sm); } while (next_permutation(v.begin(), v.end())); cout<<res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...