Submission #43772333
Source Code Expand
// LUOGU_RID: 116589446
#include<cstdio>
using namespace std;
#define Ls(i,l,r) for(int i=l;i<r;++i)
#define Rs(i,l,r) for(int i=l;i>r;--i)
#define Le(i,l,r) for(int i=l;i<=r;++i)
#define Re(i,l,r) for(int i=l;i>=r;--i)
#define L(i,l) for(int i=0;i<l;++i)
#define E(i,l) for(int i=1;i<=l;++i)
#define W(t) while(t--)
const int N=10,M=1<<N,K=N*(N-1)/2+1;
int f[N+1][M][M],n,t,m,mm,jc;
bool st[N][N],st2[M][M];
int main(){
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
// freopen("1.out","w",stdout);
// ios::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
#endif
// Insert Code Here
scanf("%d%d%d",&n,&t,&m);
E(i, m){
int a,b;
scanf("%d%d",&a,&b);
st[a-1][b-1]=1;
}
jc=1;
E(i, t)jc*=i;
mm=(1<<n)-1;
for(int i=0;i<=mm;++i)
for(int j=0;j<n;++j){
bool flag=1;
for(int k=0;k<n;++k){
int x=k<j?k:j,y=k>j?k:j;
if(i>>k&1&&st[x][y]){
flag=0;
break;
}
}
if(flag)
st2[i][1<<j]=1;
}
// printf("st2[1][2]=%d\n",st2[1][2]);
f[0][0][0]=1;
for(int i=0;i<=t;++i)
for(int j=0;j<=mm;++j)
for(int k=0;k<=mm;++k){
if(!f[i][j][k])continue;
// if(i==1&&j==1&&k==1){
// puts("Start debug!");
// }
// printf("f[%d][%d][%d]=%d\n",i,j,k,f[i][j][k]);
// for(int l=0;l<n;++l){
// if(j>>l&1)printf("have %d\n",l+1);
// }
// for(int l=0;l<n;++l){
// if(k>>l&1)printf("have chosen %d\n",l+1);
// }
int pos=k^mm;
for(;pos;pos-=pos&-pos){
int low=pos&-pos;
if(i&&st2[j][low]&&low>j){
// if(i==1&&(j|low)==11&&(k|low)==11)
// puts("Start debug!");
f[i][j|low][k|low]+=f[i][j][k];
}
if((i<t&&j)||!i){
// if(i+1==1&&low==11&&(k|low)==11)
// puts("Start debug!");
f[i+1][low][k|low]+=f[i][j][k];
}
}
}
int ans=0;
for(int i=1;i<=mm;++i)ans+=f[t][i][mm];
printf("%d",ans/jc);
return 0;
}
Submission Info
| Submission Time |
|
| Task |
D - Peaceful Teams |
| User |
WUSICHENG |
| Language |
C++ (GCC 9.2.1) |
| Score |
400 |
| Code Size |
2530 Byte |
| Status |
AC |
| Exec Time |
41 ms |
| Memory |
28144 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:23:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
23 | scanf("%d%d%d",&n,&t,&m);
| ~~~~~^~~~~~~~~~~~~~~~~~~
./Main.cpp:26:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
26 | scanf("%d%d",&a,&b);
| ~~~~~^~~~~~~~~~~~~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
400 / 400 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 02_handmade_18.txt, 02_handmade_19.txt, 02_handmade_20.txt, 02_handmade_21.txt, 02_handmade_22.txt, 02_handmade_23.txt, 02_handmade_24.txt, 02_handmade_25.txt, 02_handmade_26.txt, 02_handmade_27.txt, 02_handmade_28.txt, 02_handmade_29.txt, 02_handmade_30.txt, 02_handmade_31.txt, 03_small_32.txt, 03_small_33.txt, 03_small_34.txt, 03_small_35.txt, 03_small_36.txt, 03_small_37.txt, 03_small_38.txt, 03_small_39.txt, 03_small_40.txt, 03_small_41.txt, 03_small_42.txt, 03_small_43.txt, 03_small_44.txt, 03_small_45.txt, 03_small_46.txt, 03_small_47.txt, 03_small_48.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_00.txt |
AC |
5 ms |
1864 KiB |
| 00_sample_01.txt |
AC |
1 ms |
1788 KiB |
| 00_sample_02.txt |
AC |
2 ms |
2560 KiB |
| 00_sample_03.txt |
AC |
25 ms |
9072 KiB |
| 01_random_04.txt |
AC |
14 ms |
2968 KiB |
| 01_random_05.txt |
AC |
8 ms |
1868 KiB |
| 01_random_06.txt |
AC |
37 ms |
3324 KiB |
| 01_random_07.txt |
AC |
7 ms |
1644 KiB |
| 01_random_08.txt |
AC |
22 ms |
2328 KiB |
| 01_random_09.txt |
AC |
17 ms |
12248 KiB |
| 01_random_10.txt |
AC |
19 ms |
2504 KiB |
| 01_random_11.txt |
AC |
1 ms |
1880 KiB |
| 01_random_12.txt |
AC |
1 ms |
1844 KiB |
| 01_random_13.txt |
AC |
2 ms |
1736 KiB |
| 01_random_14.txt |
AC |
2 ms |
2044 KiB |
| 01_random_15.txt |
AC |
1 ms |
1648 KiB |
| 01_random_16.txt |
AC |
1 ms |
1768 KiB |
| 01_random_17.txt |
AC |
2 ms |
2064 KiB |
| 02_handmade_18.txt |
AC |
9 ms |
6724 KiB |
| 02_handmade_19.txt |
AC |
19 ms |
10884 KiB |
| 02_handmade_20.txt |
AC |
25 ms |
14832 KiB |
| 02_handmade_21.txt |
AC |
22 ms |
18856 KiB |
| 02_handmade_22.txt |
AC |
29 ms |
22392 KiB |
| 02_handmade_23.txt |
AC |
30 ms |
25264 KiB |
| 02_handmade_24.txt |
AC |
29 ms |
26988 KiB |
| 02_handmade_25.txt |
AC |
31 ms |
27856 KiB |
| 02_handmade_26.txt |
AC |
41 ms |
28104 KiB |
| 02_handmade_27.txt |
AC |
39 ms |
28144 KiB |
| 02_handmade_28.txt |
AC |
1 ms |
1680 KiB |
| 02_handmade_29.txt |
AC |
1 ms |
1592 KiB |
| 02_handmade_30.txt |
AC |
27 ms |
2164 KiB |
| 02_handmade_31.txt |
AC |
21 ms |
2048 KiB |
| 03_small_32.txt |
AC |
2 ms |
1620 KiB |
| 03_small_33.txt |
AC |
1 ms |
1620 KiB |
| 03_small_34.txt |
AC |
1 ms |
1624 KiB |
| 03_small_35.txt |
AC |
2 ms |
1644 KiB |
| 03_small_36.txt |
AC |
1 ms |
1624 KiB |
| 03_small_37.txt |
AC |
1 ms |
1600 KiB |
| 03_small_38.txt |
AC |
4 ms |
1700 KiB |
| 03_small_39.txt |
AC |
1 ms |
1632 KiB |
| 03_small_40.txt |
AC |
2 ms |
1580 KiB |
| 03_small_41.txt |
AC |
2 ms |
1620 KiB |
| 03_small_42.txt |
AC |
2 ms |
1668 KiB |
| 03_small_43.txt |
AC |
1 ms |
1656 KiB |
| 03_small_44.txt |
AC |
1 ms |
1652 KiB |
| 03_small_45.txt |
AC |
1 ms |
1752 KiB |
| 03_small_46.txt |
AC |
2 ms |
1616 KiB |
| 03_small_47.txt |
AC |
1 ms |
1612 KiB |
| 03_small_48.txt |
AC |
1 ms |
1600 KiB |