ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#203967 | #3572. 排列数数 | lsr | 100 | 1709ms | 34020kb | C++ | 607b | 2024-03-31 09:59:04 | 2024-03-31 12:00:38 |
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
int n,m;
int bj[33];
ll dp[5000005];
signed main(){
ios::sync_with_stdio(0);cin.tie(0);
cin>>n>>m;
for(int i=1;i<=m;++i){
int u,v;cin>>u>>v;
bj[v]|=(1<<(u-1));
}
dp[0]=1;
for(int i=0;i<(1<<n);++i){
int cnt=0;
for(int j=0;j<n;++j){
cnt+=((i>>j)&1);
}
for(int j=0;j<n;++j){
if(!((i>>j)&1)) continue;
if(((i^(1<<j))&bj[j+1])!=bj[j+1]) continue;
dp[i]=(dp[i]+dp[i^(1<<j)])%mod;
}
// cout<<i<<" "<<dp[i]<<'\n';
}
cout<<dp[(1<<n)-1]<<'\n';
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1256kb
input:
10 20 2 6 1 7 1 8 4 7 8 7 4 7 7 5 3 5 3 1 6 7 2 10 10 5 9 8 8 6 8 7 6 10 7 5 3 10 4 10 8 7
output:
210
result:
ok single line: '210'
Test #2:
score: 10
Accepted
time: 0ms
memory: 1256kb
input:
10 50 8 7 9 7 9 6 9 10 7 5 6 2 3 1 8 5 2 5 9 10 6 2 4 7 8 5 7 2 10 7 9 8 9 7 3 2 6 2 1 4 8 4 7 2 9 5...
output:
9
result:
ok single line: '9'
Test #3:
score: 10
Accepted
time: 0ms
memory: 1252kb
input:
9 3 6 7 6 5 9 1
output:
60480
result:
ok single line: '60480'
Test #4:
score: 10
Accepted
time: 0ms
memory: 1260kb
input:
10 400 7 6 4 2 6 3 6 3 4 2 1 8 10 4 1 10 10 6 4 2 10 9 10 8 10 4 5 4 1 2 9 3 5 4 4 6 10 3 10 2 8 4 9...
output:
1
result:
ok single line: '1'
Test #5:
score: 10
Accepted
time: 0ms
memory: 1260kb
input:
10 10 2 9 5 10 4 10 9 8 3 6 1 2 5 3 3 2 3 8 3 6
output:
4470
result:
ok single line: '4470'
Test #6:
score: 10
Accepted
time: 375ms
memory: 34016kb
input:
22 3 6 11 1 12 17 8
output:
700330084
result:
ok single line: '700330084'
Test #7:
score: 10
Accepted
time: 273ms
memory: 34020kb
input:
22 372 11 2 11 4 15 9 21 19 21 12 19 6 9 8 21 20 4 10 5 11 5 4 6 10 20 6 22 5 3 20 1 9 3 19 11 6 16 ...
output:
108
result:
ok single line: '108'
Test #8:
score: 10
Accepted
time: 370ms
memory: 34016kb
input:
22 40 13 17 8 2 15 1 8 18 19 13 16 20 16 15 5 6 21 14 21 13 11 3 5 8 10 9 11 1 8 17 12 21 11 4 1 21 ...
output:
291292779
result:
ok single line: '291292779'
Test #9:
score: 10
Accepted
time: 319ms
memory: 34016kb
input:
22 100 1 22 13 15 1 9 14 16 12 21 6 2 4 15 2 15 10 15 20 6 6 5 8 3 2 15 16 15 9 21 11 2 8 15 13 16 1...
output:
13220416
result:
ok single line: '13220416'
Test #10:
score: 10
Accepted
time: 372ms
memory: 34020kb
input:
22 30 4 16 1 16 18 1 3 2 5 10 21 16 4 16 11 8 8 7 20 21 19 7 6 21 19 7 1 19 5 19 21 11 10 11 10 8 19...
output:
231868313
result:
ok single line: '231868313'
Extra Test:
score: 0
Extra Test Passed