# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
697106 | 2023-02-08T10:32:51 Z | Alihan_8 | Amusement Park (CEOI19_amusementpark) | C++17 | 3000 ms | 17248 KB |
#include <bits/stdc++.h> // include <ext/pb_ds/assoc_container.hpp> // include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; #define all(x) x.begin(), x.end() #define pb push_back // define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> #define mpr make_pair #define ln '\n' void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} #define int long long signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector <int> a(m), b(m); for ( int i = 0; i < m; i++ ){ cin >> a[i] >> b[i]; a[i]--, b[i]--; } const int Mod = 998244353; vector <int> p(n); iota(all(p), 0); set <int> st; do{ vector <int> g[n], pos(n); for ( int i = 0; i < n; i++ ) pos[p[i]] = i; int rev = 0, mask = 0; for ( int i = 0; i < m; i++ ){ if ( pos[a[i]] > pos[b[i]] ){ g[b[i]].pb(a[i]); mask |= 1ll << i; } else g[a[i]].pb(b[i]); } vector <int> used(n); function <bool(int)> dfs = [&](int x){ used[x] = true; for ( auto to: g[x] ){ if ( !used[to] ){ if ( dfs(to) ) return true; } else if ( used[to] == 1 ) return true; } used[x] = 2; return false; }; bool flag = true; for ( int i = 0; i < n; i++ ){ if ( !used[i] and dfs(i) ){ flag = false; break; } } if ( flag ) st.insert(mask); } while ( next_permutation(all(p)) ); int cnt = 0; auto f = [&](int x){ return __builtin_popcountll(x); }; for ( auto i: st ) cnt = (cnt+f(i))%Mod; cout << cnt; cout << '\n'; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 316 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 320 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 316 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 320 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 324 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 324 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 320 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 316 KB | Output is correct |
19 | Correct | 1 ms | 316 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 320 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 316 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 320 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 324 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 324 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 320 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 316 KB | Output is correct |
19 | Correct | 1 ms | 316 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 320 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 2 ms | 320 KB | Output is correct |
26 | Correct | 2 ms | 212 KB | Output is correct |
27 | Correct | 4 ms | 328 KB | Output is correct |
28 | Correct | 4 ms | 340 KB | Output is correct |
29 | Correct | 5 ms | 340 KB | Output is correct |
30 | Correct | 5 ms | 448 KB | Output is correct |
31 | Correct | 6 ms | 448 KB | Output is correct |
32 | Correct | 16 ms | 212 KB | Output is correct |
33 | Correct | 19 ms | 212 KB | Output is correct |
34 | Correct | 26 ms | 364 KB | Output is correct |
35 | Correct | 31 ms | 468 KB | Output is correct |
36 | Correct | 38 ms | 716 KB | Output is correct |
37 | Correct | 47 ms | 1400 KB | Output is correct |
38 | Correct | 50 ms | 2168 KB | Output is correct |
39 | Correct | 111 ms | 304 KB | Output is correct |
40 | Correct | 166 ms | 308 KB | Output is correct |
41 | Correct | 229 ms | 352 KB | Output is correct |
42 | Correct | 266 ms | 536 KB | Output is correct |
43 | Correct | 325 ms | 1568 KB | Output is correct |
44 | Correct | 412 ms | 2740 KB | Output is correct |
45 | Correct | 438 ms | 5804 KB | Output is correct |
46 | Correct | 495 ms | 10980 KB | Output is correct |
47 | Correct | 547 ms | 17248 KB | Output is correct |
48 | Correct | 155 ms | 212 KB | Output is correct |
49 | Correct | 243 ms | 508 KB | Output is correct |
50 | Correct | 247 ms | 512 KB | Output is correct |
51 | Correct | 234 ms | 464 KB | Output is correct |
52 | Correct | 1306 ms | 304 KB | Output is correct |
53 | Correct | 1923 ms | 460 KB | Output is correct |
54 | Correct | 2531 ms | 708 KB | Output is correct |
55 | Execution timed out | 3061 ms | 1800 KB | Time limit exceeded |
56 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 316 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 320 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 324 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 324 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 320 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 316 KB | Output is correct |
19 | Correct | 1 ms | 316 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 320 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 2 ms | 320 KB | Output is correct |
26 | Correct | 2 ms | 212 KB | Output is correct |
27 | Correct | 4 ms | 328 KB | Output is correct |
28 | Correct | 4 ms | 340 KB | Output is correct |
29 | Correct | 5 ms | 340 KB | Output is correct |
30 | Correct | 5 ms | 448 KB | Output is correct |
31 | Correct | 6 ms | 448 KB | Output is correct |
32 | Correct | 16 ms | 212 KB | Output is correct |
33 | Correct | 19 ms | 212 KB | Output is correct |
34 | Correct | 26 ms | 364 KB | Output is correct |
35 | Correct | 31 ms | 468 KB | Output is correct |
36 | Correct | 38 ms | 716 KB | Output is correct |
37 | Correct | 47 ms | 1400 KB | Output is correct |
38 | Correct | 50 ms | 2168 KB | Output is correct |
39 | Correct | 111 ms | 304 KB | Output is correct |
40 | Correct | 166 ms | 308 KB | Output is correct |
41 | Correct | 229 ms | 352 KB | Output is correct |
42 | Correct | 266 ms | 536 KB | Output is correct |
43 | Correct | 325 ms | 1568 KB | Output is correct |
44 | Correct | 412 ms | 2740 KB | Output is correct |
45 | Correct | 438 ms | 5804 KB | Output is correct |
46 | Correct | 495 ms | 10980 KB | Output is correct |
47 | Correct | 547 ms | 17248 KB | Output is correct |
48 | Correct | 155 ms | 212 KB | Output is correct |
49 | Correct | 243 ms | 508 KB | Output is correct |
50 | Correct | 247 ms | 512 KB | Output is correct |
51 | Correct | 234 ms | 464 KB | Output is correct |
52 | Correct | 1306 ms | 304 KB | Output is correct |
53 | Correct | 1923 ms | 460 KB | Output is correct |
54 | Correct | 2531 ms | 708 KB | Output is correct |
55 | Execution timed out | 3061 ms | 1800 KB | Time limit exceeded |
56 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 316 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 320 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 324 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 324 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 320 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 316 KB | Output is correct |
19 | Correct | 1 ms | 316 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 212 KB | Output is correct |
23 | Correct | 1 ms | 320 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 2 ms | 320 KB | Output is correct |
26 | Correct | 2 ms | 212 KB | Output is correct |
27 | Correct | 4 ms | 328 KB | Output is correct |
28 | Correct | 4 ms | 340 KB | Output is correct |
29 | Correct | 5 ms | 340 KB | Output is correct |
30 | Correct | 5 ms | 448 KB | Output is correct |
31 | Correct | 6 ms | 448 KB | Output is correct |
32 | Correct | 16 ms | 212 KB | Output is correct |
33 | Correct | 19 ms | 212 KB | Output is correct |
34 | Correct | 26 ms | 364 KB | Output is correct |
35 | Correct | 31 ms | 468 KB | Output is correct |
36 | Correct | 38 ms | 716 KB | Output is correct |
37 | Correct | 47 ms | 1400 KB | Output is correct |
38 | Correct | 50 ms | 2168 KB | Output is correct |
39 | Correct | 111 ms | 304 KB | Output is correct |
40 | Correct | 166 ms | 308 KB | Output is correct |
41 | Correct | 229 ms | 352 KB | Output is correct |
42 | Correct | 266 ms | 536 KB | Output is correct |
43 | Correct | 325 ms | 1568 KB | Output is correct |
44 | Correct | 412 ms | 2740 KB | Output is correct |
45 | Correct | 438 ms | 5804 KB | Output is correct |
46 | Correct | 495 ms | 10980 KB | Output is correct |
47 | Correct | 547 ms | 17248 KB | Output is correct |
48 | Correct | 155 ms | 212 KB | Output is correct |
49 | Correct | 243 ms | 508 KB | Output is correct |
50 | Correct | 247 ms | 512 KB | Output is correct |
51 | Correct | 234 ms | 464 KB | Output is correct |
52 | Correct | 1306 ms | 304 KB | Output is correct |
53 | Correct | 1923 ms | 460 KB | Output is correct |
54 | Correct | 2531 ms | 708 KB | Output is correct |
55 | Execution timed out | 3061 ms | 1800 KB | Time limit exceeded |
56 | Halted | 0 ms | 0 KB | - |