# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
945655 | 2024-03-14T06:04:38 Z | vjudge1 | Amusement Park (CEOI19_amusementpark) | C++17 | 1 ms | 348 KB |
#include <bits/stdc++.h> #define int long long #define all(x) x.begin(),x.end() #define ff first #define ss second #define pb push_back using namespace std; vector <int> g[20]; int cl[20]; bool ok=1; void dfs(int v){ cl[v]=1; for(auto to : g[v]){ if(cl[to]==0)dfs(to); else if(cl[to]==1)ok=0; } cl[v]=2; } signed main(){ int n,m; cin>>n>>m; vector <int> u(m),v(m); for(int i=0;i<m;i++){ cin>>u[i]>>v[i]; } vector <int> ord; int ans=0; for(int i=1;i<=n;i++)ord.pb(i); do{ vector <int> val_ord(n+1); for(int i=1;i<=n;i++){ cl[i]=0; g[i].clear(); } ok=1; for(int i=0;i<ord.size();i++){ val_ord[ord[i]]=i; } int cnt=0; for(int i=0;i<m;i++){ int x=val_ord[u[i]]; int y=val_ord[v[i]]; if(x<y){ cnt++; g[v[i]].pb(u[i]); } else g[u[i]].pb(v[i]); } for(int i=1;i<=n;i++){ if(!cl[i])dfs(i); } if(ok){ ans+=cnt; } }while(next_permutation(all(ord))); cout<<ans<<"\n"; } /* 3 3 1 2 2 3 1 3 1 2 3 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |