| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 814940 | jajco | Jail (JOI22_jail) | C++17 | 5064 ms | 312 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <ios>
#include <vector>
#include <algorithm>
#include <functional>
#define REP(i, n) for (int i=0; i<n; ++i)
typedef std::vector <int> vi;
int main(){
int q;
scanf("%d", &q);
while (q--){
int n;
scanf("%d", &n);
std::vector <vi> pol(n+1, vi());
REP(i, n-1){
int p,k;
scanf("%d%d", &p, &k);
pol[p].emplace_back(k);
pol[k].emplace_back(p);
}
int m;
scanf("%d", &m);
vi pocz(m),kon(m),perm;
REP(i, m){
scanf("%d%d", &pocz[i], &kon[i]);
perm.emplace_back(i);
}
bool czy=0;
while (1){
std::vector <bool> zaj(n+1, 0);
for (int i : pocz)
zaj[i]=1;
std::function <bool(int, int, int)> DFS=[&](
int i, int ojc, int d){
if (i==d)
return true;
bool r=0;
for (int j : pol[i])
if (j!=ojc&&!zaj[j])
r|=DFS(j, i, d);
return r;
};
bool w=1;
for (int i : perm){
if (!(w&=DFS(pocz[i], pocz[i], kon[i])))
break;
zaj[pocz[i]]=0,zaj[kon[i]]=1;
}
czy|=w;
if (czy||!std::next_permutation(perm.begin(), perm.end()))
break;
}
printf(czy ? "Yes\n" : "No\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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
