# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
697100 | 2023-02-08T10:02:18 Z | Alihan_8 | Amusement Park (CEOI19_amusementpark) | C++17 | 569 ms | 10792 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 |= 1 << 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_popcount(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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 316 KB | Output is correct |
12 | Correct | 0 ms | 316 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 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 | 340 KB | Output is correct |
24 | Correct | 1 ms | 316 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 316 KB | Output is correct |
12 | Correct | 0 ms | 316 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 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 | 340 KB | Output is correct |
24 | Correct | 1 ms | 316 KB | Output is correct |
25 | Correct | 2 ms | 212 KB | Output is correct |
26 | Correct | 2 ms | 212 KB | Output is correct |
27 | Correct | 3 ms | 212 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 | 340 KB | Output is correct |
31 | Correct | 6 ms | 468 KB | Output is correct |
32 | Correct | 12 ms | 212 KB | Output is correct |
33 | Correct | 18 ms | 212 KB | Output is correct |
34 | Correct | 26 ms | 376 KB | Output is correct |
35 | Correct | 32 ms | 460 KB | Output is correct |
36 | Correct | 39 ms | 788 KB | Output is correct |
37 | Correct | 45 ms | 1404 KB | Output is correct |
38 | Correct | 49 ms | 2088 KB | Output is correct |
39 | Correct | 113 ms | 304 KB | Output is correct |
40 | Correct | 167 ms | 320 KB | Output is correct |
41 | Correct | 224 ms | 364 KB | Output is correct |
42 | Correct | 267 ms | 544 KB | Output is correct |
43 | Correct | 333 ms | 1836 KB | Output is correct |
44 | Correct | 389 ms | 2840 KB | Output is correct |
45 | Correct | 445 ms | 5812 KB | Output is correct |
46 | Correct | 473 ms | 10792 KB | Output is correct |
47 | Incorrect | 569 ms | 10528 KB | Output isn't correct |
48 | 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 316 KB | Output is correct |
12 | Correct | 0 ms | 316 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 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 | 340 KB | Output is correct |
24 | Correct | 1 ms | 316 KB | Output is correct |
25 | Correct | 2 ms | 212 KB | Output is correct |
26 | Correct | 2 ms | 212 KB | Output is correct |
27 | Correct | 3 ms | 212 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 | 340 KB | Output is correct |
31 | Correct | 6 ms | 468 KB | Output is correct |
32 | Correct | 12 ms | 212 KB | Output is correct |
33 | Correct | 18 ms | 212 KB | Output is correct |
34 | Correct | 26 ms | 376 KB | Output is correct |
35 | Correct | 32 ms | 460 KB | Output is correct |
36 | Correct | 39 ms | 788 KB | Output is correct |
37 | Correct | 45 ms | 1404 KB | Output is correct |
38 | Correct | 49 ms | 2088 KB | Output is correct |
39 | Correct | 113 ms | 304 KB | Output is correct |
40 | Correct | 167 ms | 320 KB | Output is correct |
41 | Correct | 224 ms | 364 KB | Output is correct |
42 | Correct | 267 ms | 544 KB | Output is correct |
43 | Correct | 333 ms | 1836 KB | Output is correct |
44 | Correct | 389 ms | 2840 KB | Output is correct |
45 | Correct | 445 ms | 5812 KB | Output is correct |
46 | Correct | 473 ms | 10792 KB | Output is correct |
47 | Incorrect | 569 ms | 10528 KB | Output isn't correct |
48 | 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 316 KB | Output is correct |
12 | Correct | 0 ms | 316 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 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 | 340 KB | Output is correct |
24 | Correct | 1 ms | 316 KB | Output is correct |
25 | Correct | 2 ms | 212 KB | Output is correct |
26 | Correct | 2 ms | 212 KB | Output is correct |
27 | Correct | 3 ms | 212 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 | 340 KB | Output is correct |
31 | Correct | 6 ms | 468 KB | Output is correct |
32 | Correct | 12 ms | 212 KB | Output is correct |
33 | Correct | 18 ms | 212 KB | Output is correct |
34 | Correct | 26 ms | 376 KB | Output is correct |
35 | Correct | 32 ms | 460 KB | Output is correct |
36 | Correct | 39 ms | 788 KB | Output is correct |
37 | Correct | 45 ms | 1404 KB | Output is correct |
38 | Correct | 49 ms | 2088 KB | Output is correct |
39 | Correct | 113 ms | 304 KB | Output is correct |
40 | Correct | 167 ms | 320 KB | Output is correct |
41 | Correct | 224 ms | 364 KB | Output is correct |
42 | Correct | 267 ms | 544 KB | Output is correct |
43 | Correct | 333 ms | 1836 KB | Output is correct |
44 | Correct | 389 ms | 2840 KB | Output is correct |
45 | Correct | 445 ms | 5812 KB | Output is correct |
46 | Correct | 473 ms | 10792 KB | Output is correct |
47 | Incorrect | 569 ms | 10528 KB | Output isn't correct |
48 | Halted | 0 ms | 0 KB | - |