# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
697099 | 2023-02-08T09:58:43 Z | Alihan_8 | Amusement Park (CEOI19_amusementpark) | C++17 | 1 ms | 264 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); int cnt = 0; do{ vector <int> g[n], pos(n); for ( int i = 0; i < n; i++ ) pos[p[i]] = i; int rev = 0; for ( int i = 0; i < m; i++ ){ if ( pos[a[i]] > pos[b[i]] ){ g[b[i]].pb(a[i]); rev++; } 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; } } cnt = (cnt+flag*rev)%Mod; } while ( next_permutation(all(p)) ); cout << cnt; cout << '\n'; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 264 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 264 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 264 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 264 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 264 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |