| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 895892 | magician | Amusement Park (CEOI19_amusementpark) | C++14 | 1 ms | 456 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define FORU(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
#define MASK(x) (1 << (x))
#define BIT(x, i) (((x) >> (i)) & 1)
#define TASK "AMUSEMENTPARK"
#define fi first
#define se second
using namespace std;
const int NMAX = 20, MMAX = 200;
int N, M;
pair<int, int> e[MMAX];
vector<int> adj[NMAX];
namespace subtask1 {
bool is_sub(void) {
return N <= 3;
}
int vis[NMAX];
bool dfs(int u, int mask) {
vis[u] = 1;
for(int id : adj[u]) {
int v = e[id].fi + e[id].se - u;
if(!BIT(mask, id - 1) && u == e[id].se) continue;
if(BIT(mask, id - 1) && u == e[id].fi) continue;
if(vis[v] == 1) return false;
if(vis[v] == 0) if(!dfs(v, mask)) return false;
}
vis[u] = 2;
return true;
}
bool chk(int mask) {
FORU(i, 1, N) vis[i] = 0;
FORU(i, 1, N)
if(vis[i] == 0) if(!dfs(i, mask)) return false;
return true;
}
void sol(void) {
int ans = 0;
FORU(mask, 0, MASK(M) - 1) {
if(chk(mask)) {
ans += __builtin_popcount(mask);
}
}
cout << ans;
return;
}
}
int main(void) {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(TASK".INP", "r")) {
freopen(TASK".INP", "r", stdin);
freopen(TASK".OUT", "w", stdout);
}
cin >> N >> M;
FORU(i, 1, M) {
cin >> e[i].fi >> e[i].se;
adj[e[i].fi].push_back(i);
adj[e[i].se].push_back(i);
}
if(subtask1::is_sub()) return subtask1::sol(), 0;
}
컴파일 시 표준 에러 (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... | ||||
