# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
502531 | InternetPerson10 | Amusement Park (CEOI19_amusementpark) | C++17 | 3062 ms | 324 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool bad[20][20];
const ll MOD = 998244353;
int main() {
int n, m;
cin >> n >> m;
vector<pair<int, int>> edges(m);
for(int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
x--; y--;
edges[i] = {x, y};
bad[y][x] = true;
}
ll ans = 0;
vector<int> nums(n);
for(int i = 0; i < n; i++) nums[i] = i;
for(int i = 0; i < (1 << m); i++) {
vector<vector<int>> adj(n);
for(int j = 0; j < m; j++) {
if(i & (1 << j)) swap(edges[j].first, edges[j].second);
adj[edges[j].first].push_back(edges[j].second);
}
bool ok = true;
queue<int> q;
vector<bool> done(n);
for(int j = 0; j < n; j++) {
if(adj[j].size() == 0) {
q.push(j);
done[j] = true;
}
}
while(q.size()) {
int p = q.front(); q.pop();
for(int j = 0; j < n; j++) {
for(int k = 0; k < adj[j].size(); k++) {
if(adj[j][k] == p) {
adj[j].erase(adj[j].begin() + k);
break;
}
}
if(adj[j].size() == 0 && !done[j]) {
q.push(j);
done[j] = true;
}
}
}
int g = 0;
for(int j = 0; j < n; j++) {
if(!done[j]) ok = false;
}
for(int j = 0; j < m; j++) {
if(i & (1 << j)) {
swap(edges[j].first, edges[j].second);
g++;
}
}
if(ok) ans += g;
}
cout << ans << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |