Untitled
unknown
plain_text
2 years ago
1.1 kB
4
Indexable
Never
#pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #include<bits/stdc++.h> using namespace std; vector<vector<long long>>dothi(100000000); map<long long,long long>visited; long long d=0; void demduongdi(long long cur,long long end) { visited[cur]=true; if(cur==end) { d++; } else { for(auto i=dothi[cur].begin();i!=dothi[cur].end();i++) { if(!visited[*i]) { demduongdi(*i,end); } } } visited[cur]=false; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen("input.inp","r",stdin); freopen("output.out","w",stdout); #else #endif long long n,m; cin>>n>>m; for(int i=1;i<=m;i++) { long long x,y; cin>>x>>y; dothi[x].push_back(y); } for(int i=1;i<=n;i++) { visited[i]=false; } demduongdi(1,n); cout<<d; return 0; }