| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 290754 | TadijaSebez | Fun Tour (APIO20_fun) | C++11 | 1 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fun.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
int SUB(int root,int x){return attractionsBehind(root,x);}
int DEP(int root,int x){return hoursRequired(root,x);}
const int N=100050;
int dep[N],sz[N];
int FindCentroid(int n){
pii mx={0,0};
for(int i=1;i<n;i++){
sz[i]=SUB(0,i);
dep[i]=DEP(0,i);
if(sz[i]*2>=n)mx=max(mx,{dep[i],i});
}
return mx.second;
}
int type[N],dist[N];
vector<int> createFunTour(int n,int q){
int cen=FindCentroid(n);
vector<int> f;
for(int i=0;i<n;i++){
dist[i]=DEP(cen,i);
if(dist[i]==1&&dep[i]==dep[cen]+1){
f.pb(i);
type[i]=f.size();
}
}
type[cen]=-1;
for(int j=0;j<f.size();j++){
for(int i=0;i<n;i++)if(!type[i]){
if(SUB(i,f[j])==n-sz[f[j]]+1)type[i]=j+1;
}
}
for(int i=0;i<n;i++)if(!type[i])type[i]=3;
priority_queue<pii> pq[3];
for(int i=0;i<n;i++)if(type[i]>0)pq[type[i]-1].push({dist[i],i});
vector<int> ans;
int ban=-1;
while(1){
int mx=0,sz=0,o=-1;
for(int i=0;i<3;i++)if(i!=ban){
if(pq[i].size()){
int now=pq[i].top().first;
if(now>mx||(now==mx&&sz<pq[i].size()))mx=now,sz=pq[i].size(),o=i;
}
}
if(o==-1)break;
ban=o;
ans.pb(pq[o].top().second);
pq[o].pop();
}
ans.pb(cen);
return ans;
}컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
