| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1081454 | LCJLY | The Ties That Guide Us (CEOI23_incursion) | C++17 | 3045 ms | 7560 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "incursion.h"
#include <bits/stdc++.h>
//#include "sample_grader.cpp"
using namespace std;
//#define int long long
//#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << #i << " " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<int,int>pii;
typedef pair<pii,int>pi2;
int n;
vector<int>adj[45005];
int pp[45005];
void dfs(int index, int par){
for(auto it:adj[index]){
if(it==par) continue;
pp[it]=index;
dfs(it,index);
}
}
vector<int>mark(vector<pair<int, int>> F, int safe){
n=F.size()+1;
for(int x=0;x<n-1;x++){
adj[F[x].first].push_back(F[x].second);
adj[F[x].second].push_back(F[x].first);
}
int rt=0;
for(int x=1;x<=n;x++){
if(adj[x].size()==2){
dfs(x,-1);
rt=x;
}
}
vector<int>ans(n,0);
int cur=safe;
while(1){
ans[cur-1]=1;
if(cur==rt) break;
cur=pp[cur];
}
return ans;
}
//visit()
void locate(vector<pair<int, int>> F, int curr, int t){
n=F.size()+1;
for(int x=0;x<=n;x++){
adj[x].clear();
}
for(int x=0;x<n-1;x++){
adj[F[x].first].push_back(F[x].second);
adj[F[x].second].push_back(F[x].first);
}
memset(pp,0,sizeof(pp));
for(int x=1;x<=n;x++){
if(adj[x].size()==2){
dfs(x,-1);
}
}
bool done[n+5];
memset(done,0,sizeof(done));
while(1){
if(t==0){
//go up
done[curr]=true;
t=visit(pp[curr]);
curr=pp[curr];
}
else{
//go down
bool take=false;
for(auto it:adj[curr]){
if(it==pp[curr]) continue;
if(done[it]) continue;
t=visit(it);
curr=it;
take=true;
}
if(!take) return;
}
}
}
컴파일 시 표준 에러 (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... | ||||
