Submission #2203395
Source Code Expand
#include <iostream> #include <vector> #include <map> #include <utility> #include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <stack> #include <queue> #include <set> #include <unordered_map> #include <unordered_set> #define REP(i,a,n) for(int i=a;i<n;++i) #define rep(i,n) REP(i,0,n) #define REV(i,a,n) for(int i=n;i>=a;--i) #define all(e) e.begin(),e.end() #define rall(e) e.rbegin(),e.rend() #define pb push_back #define mp make_pair #define fs first #define sc second #define show(n) cerr<<#n<<" = "<<n<<endl #define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl //ここからAtCoder向けdefine #define yes cout << "YES" << endl #define no cout << "NO" << endl using namespace std; using ll = long long; using ull = unsigned long long; using vi = vector<int>; using pint = pair<int,int>; const int INF = ~(1 << 31); vi lm[17]; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; //vi lm[n]; int a, b; rep(i, m){ cin >> a >> b; a--;b--; lm[a].pb(b); } vi v(n); rep(i, n){ v[i] = i; } ll ans = 0; bool f; int l; do{ //shows(v); f = true; rep(i, n){ rep(j, n){ if(v[j] == i){ l = j;break; } } //show(l); rep(j, lm[i].size()){ //show(lm[i][j]); rep(k, n){ if(v[k] == lm[i][j]){ //cerr << l << " " << k << endl; if(l > k){f = false;break;} } } if(!f){break;} } } if(f){ans++;} }while(next_permutation(all(v))); cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 徒競走 |
User | Shinjirow |
Language | C++14 (Clang 3.8.0) |
Score | 30 |
Code Size | 1896 Byte |
Status | TLE |
Exec Time | 3155 ms |
Memory | 888 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 30 / 30 | 0 / 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 | 9 ms | 888 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | TLE | 3155 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 5 ms | 256 KB |
1_02.txt | AC | 8 ms | 256 KB |
1_03.txt | AC | 7 ms | 256 KB |
1_04.txt | AC | 7 ms | 256 KB |
1_05.txt | AC | 2 ms | 256 KB |
1_06.txt | AC | 2 ms | 256 KB |
1_07.txt | AC | 2 ms | 256 KB |
1_08.txt | AC | 2 ms | 256 KB |
1_09.txt | AC | 7 ms | 256 KB |
1_10.txt | AC | 8 ms | 256 KB |
1_11.txt | AC | 5 ms | 256 KB |
1_12.txt | AC | 8 ms | 256 KB |
2_00.txt | TLE | 3155 ms | 256 KB |
2_01.txt | TLE | 3155 ms | 256 KB |
2_02.txt | TLE | 3155 ms | 256 KB |
2_03.txt | TLE | 3155 ms | 256 KB |
2_04.txt | TLE | 3155 ms | 256 KB |
2_05.txt | TLE | 3155 ms | 256 KB |
2_06.txt | TLE | 3155 ms | 256 KB |
2_07.txt | TLE | 3155 ms | 256 KB |
2_08.txt | TLE | 3155 ms | 256 KB |
2_09.txt | TLE | 3155 ms | 256 KB |
2_10.txt | TLE | 3155 ms | 256 KB |
2_11.txt | TLE | 3155 ms | 256 KB |
2_12.txt | TLE | 3155 ms | 256 KB |
2_13.txt | TLE | 3155 ms | 256 KB |
2_14.txt | TLE | 3155 ms | 256 KB |
2_15.txt | TLE | 3155 ms | 256 KB |