# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211244 | 2020-03-19T18:00:47 Z | Lawliet | Amusement Park (CEOI19_amusementpark) | C++17 | 3000 ms | 512 KB |
#include <bits/stdc++.h> using namespace std; typedef long long int lli; typedef pair<int,int> pii; const int MAXN = 20; int n, m; int ingrau[MAXN]; vector< int > adj[MAXN]; vector< pii > edges; bool hasCycle() { queue< int > q; for(int i = 1 ; i <= n ; i++) if( ingrau[i] == 0 ) q.push( i ); int cnt = 0; while( !q.empty() ) { int cur = q.front(); q.pop(); cnt++; for(int i = 0 ; i < adj[cur].size() ; i++) { int viz = adj[cur][i]; if( --ingrau[viz] == 0 ) q.push( viz ); } } return ( cnt != n ); } int main() { scanf("%d %d",&n,&m); for(int i = 1 ; i <= m ; i++) { int U, V; scanf("%d %d",&U,&V); edges.push_back( { U , V } ); } lli ans = 0; for(int mask = 0 ; mask < (1 << m) ; mask++) { for(int i = 1 ; i <= n ; i++) { ingrau[i] = 0; adj[i].clear(); } for(int i = 0 ; i < m ; i++) { int U = edges[i].first; int V = edges[i].second; if( mask & (1 << i) ) swap( U , V ); ingrau[V]++; adj[U].push_back( V ); } if( !hasCycle() ) ans += __builtin_popcount( mask ); } printf("%lld\n",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 256 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 5 ms | 256 KB | Output is correct |
12 | Correct | 5 ms | 256 KB | Output is correct |
13 | Correct | 5 ms | 256 KB | Output is correct |
14 | Correct | 5 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 256 KB | Output is correct |
16 | Correct | 5 ms | 256 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 256 KB | Output is correct |
19 | Correct | 5 ms | 256 KB | Output is correct |
20 | Correct | 5 ms | 256 KB | Output is correct |
21 | Correct | 5 ms | 256 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 6 ms | 256 KB | Output is correct |
24 | Correct | 13 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 256 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 5 ms | 256 KB | Output is correct |
12 | Correct | 5 ms | 256 KB | Output is correct |
13 | Correct | 5 ms | 256 KB | Output is correct |
14 | Correct | 5 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 256 KB | Output is correct |
16 | Correct | 5 ms | 256 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 256 KB | Output is correct |
19 | Correct | 5 ms | 256 KB | Output is correct |
20 | Correct | 5 ms | 256 KB | Output is correct |
21 | Correct | 5 ms | 256 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 6 ms | 256 KB | Output is correct |
24 | Correct | 13 ms | 256 KB | Output is correct |
25 | Correct | 5 ms | 256 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 256 KB | Output is correct |
28 | Correct | 6 ms | 256 KB | Output is correct |
29 | Correct | 13 ms | 256 KB | Output is correct |
30 | Correct | 71 ms | 256 KB | Output is correct |
31 | Correct | 559 ms | 256 KB | Output is correct |
32 | Correct | 5 ms | 256 KB | Output is correct |
33 | Correct | 5 ms | 256 KB | Output is correct |
34 | Correct | 6 ms | 256 KB | Output is correct |
35 | Correct | 22 ms | 256 KB | Output is correct |
36 | Correct | 320 ms | 504 KB | Output is correct |
37 | Execution timed out | 3076 ms | 384 KB | Time limit exceeded |
38 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 256 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 5 ms | 256 KB | Output is correct |
12 | Correct | 5 ms | 256 KB | Output is correct |
13 | Correct | 5 ms | 256 KB | Output is correct |
14 | Correct | 5 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 256 KB | Output is correct |
16 | Correct | 5 ms | 256 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 256 KB | Output is correct |
19 | Correct | 5 ms | 256 KB | Output is correct |
20 | Correct | 5 ms | 256 KB | Output is correct |
21 | Correct | 5 ms | 256 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 6 ms | 256 KB | Output is correct |
24 | Correct | 13 ms | 256 KB | Output is correct |
25 | Correct | 5 ms | 256 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 256 KB | Output is correct |
28 | Correct | 6 ms | 256 KB | Output is correct |
29 | Correct | 13 ms | 256 KB | Output is correct |
30 | Correct | 71 ms | 256 KB | Output is correct |
31 | Correct | 559 ms | 256 KB | Output is correct |
32 | Correct | 5 ms | 256 KB | Output is correct |
33 | Correct | 5 ms | 256 KB | Output is correct |
34 | Correct | 6 ms | 256 KB | Output is correct |
35 | Correct | 22 ms | 256 KB | Output is correct |
36 | Correct | 320 ms | 504 KB | Output is correct |
37 | Execution timed out | 3076 ms | 384 KB | Time limit exceeded |
38 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 256 KB | Output is correct |
10 | Correct | 5 ms | 512 KB | Output is correct |
11 | Correct | 5 ms | 256 KB | Output is correct |
12 | Correct | 5 ms | 256 KB | Output is correct |
13 | Correct | 5 ms | 256 KB | Output is correct |
14 | Correct | 5 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 256 KB | Output is correct |
16 | Correct | 5 ms | 256 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 256 KB | Output is correct |
19 | Correct | 5 ms | 256 KB | Output is correct |
20 | Correct | 5 ms | 256 KB | Output is correct |
21 | Correct | 5 ms | 256 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 6 ms | 256 KB | Output is correct |
24 | Correct | 13 ms | 256 KB | Output is correct |
25 | Correct | 5 ms | 256 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 256 KB | Output is correct |
28 | Correct | 6 ms | 256 KB | Output is correct |
29 | Correct | 13 ms | 256 KB | Output is correct |
30 | Correct | 71 ms | 256 KB | Output is correct |
31 | Correct | 559 ms | 256 KB | Output is correct |
32 | Correct | 5 ms | 256 KB | Output is correct |
33 | Correct | 5 ms | 256 KB | Output is correct |
34 | Correct | 6 ms | 256 KB | Output is correct |
35 | Correct | 22 ms | 256 KB | Output is correct |
36 | Correct | 320 ms | 504 KB | Output is correct |
37 | Execution timed out | 3076 ms | 384 KB | Time limit exceeded |
38 | Halted | 0 ms | 0 KB | - |