| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 208272 | rzbt | Zagrade (COI17_zagrade) | C++14 | 10 ms | 5880 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define MAXN 100005
using namespace std;
int n;
char s[MAXN];
int zagrada[MAXN];
vector<int> niz[MAXN];
int obradjen[MAXN];
int podst[MAXN];
int cale[MAXN];
int dfsV(int t,int o){
podst[t]=1;
cale[t]=o;
for(auto x:niz[t])
if(x!=o && !obradjen[x])
podst[t]+=dfsV(x,t);
return podst[t];
}
void centroidna(int c){
dfsV(c,0);
int vel=podst[c];
if(vel==1){
printf(" jedan %d\n",c);
obradjen[c]=true;
return;
}
while(22){
bool naso=false;
for(auto x:niz[c]){
if(obradjen[x] || x==cale[c])continue;
if(podst[x]>(vel>>1)){
c=x;
naso=true;
break;
}
}
if(!naso)break;
}
/// OVDE IDE OBRADA
///OVDE JE KRAJ OVRADE
printf(" vise %d\n",c);
obradjen[c]=true;
for(auto x:niz[c]){
if(!obradjen[x])centroidna(x);
}
}
int main()
{
scanf("%d", &n);
scanf("%s",s);
for(int i=1;i<=n;i++)
zagrada[i]=(s[i-1]=='('?1:-1);
for(int i=1;i<n;i++){
int t1,t2;
scanf("%d %d", &t1, &t2);
niz[t1].pb(t2);
niz[t2].pb(t1);
}
centroidna(1);
return 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... | ||||
