Submission #3000901
Source Code Expand
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define INF (1<<30) #define INFLL (1ll<<60) typedef pair<int, int> P; typedef pair<int, P> E; #define MOD (1000000007ll) #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %= MOD; } void add_mod(ll& a, ll b){ b += MOD; a += b; a %= MOD; } ll dp[66666]; vector<int> g[20]; int main(void){ int n,m,i,j,k,t,x,y; bool used[20],flag; fill(dp,dp+66666,0ll); cin >> n >> m; t = (1<<n); for(j=0; j<m; ++j){ cin >> x >> y; --x; --y; g[y].push_back(x); } dp[0] = 1ll; for(i=0; i<t; ++i){ fill(used,used+20,false); for(j=0; j<n; ++j){ if(i&(1<<j)){ used[j] = true; } } for(j=0; j<n; ++j){ if(used[j]){ continue; } flag = true; for(k=(g[j].l_ength()-1); k>=0; --k){ if(!used[g[j][k]]){ flag = false; break; } } if(flag){ dp[i+(1<<j)] += dp[i]; } } } cout << (dp[t-1]) << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 徒競走 |
User | ransewhale |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 1008 Byte |
Status | AC |
Exec Time | 12 ms |
Memory | 768 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 30 / 30 | 70 / 70 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
Subtask1 | 0_00.txt, 0_01.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 768 KB |
0_01.txt | AC | 1 ms | 768 KB |
0_02.txt | AC | 10 ms | 768 KB |
1_00.txt | AC | 1 ms | 768 KB |
1_01.txt | AC | 2 ms | 768 KB |
1_02.txt | AC | 2 ms | 768 KB |
1_03.txt | AC | 2 ms | 768 KB |
1_04.txt | AC | 1 ms | 768 KB |
1_05.txt | AC | 1 ms | 768 KB |
1_06.txt | AC | 1 ms | 768 KB |
1_07.txt | AC | 1 ms | 768 KB |
1_08.txt | AC | 1 ms | 768 KB |
1_09.txt | AC | 2 ms | 768 KB |
1_10.txt | AC | 1 ms | 768 KB |
1_11.txt | AC | 1 ms | 768 KB |
1_12.txt | AC | 1 ms | 768 KB |
2_00.txt | AC | 10 ms | 768 KB |
2_01.txt | AC | 11 ms | 768 KB |
2_02.txt | AC | 11 ms | 768 KB |
2_03.txt | AC | 11 ms | 768 KB |
2_04.txt | AC | 7 ms | 768 KB |
2_05.txt | AC | 6 ms | 768 KB |
2_06.txt | AC | 7 ms | 768 KB |
2_07.txt | AC | 7 ms | 768 KB |
2_08.txt | AC | 11 ms | 768 KB |
2_09.txt | AC | 12 ms | 768 KB |
2_10.txt | AC | 11 ms | 768 KB |
2_11.txt | AC | 11 ms | 768 KB |
2_12.txt | AC | 11 ms | 768 KB |
2_13.txt | AC | 11 ms | 768 KB |
2_14.txt | AC | 11 ms | 768 KB |
2_15.txt | AC | 10 ms | 768 KB |