QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#859612 | #9678. 网友小 Z 的树 | Zaunese | 0 | 1ms | 15100kb | C++14 | 2.0kb | 2025-01-17 21:06:56 | 2025-01-17 21:09:15 |
Judging History
answer
// 위대한 - 주의 만세!
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include"diameter.h"
#define fi first
#define se second
#define mkp std::make_pair
using llu=long long unsigned;
using ll=long long;
using std::max;
using std::min;
template<class T> void cmax(T&a,T b){a=max(a,b);}
template<class T> void cmin(T&a,T b){a=min(a,b);}
std::pair<int,int> find_diameter(int sid,int N){
if(N==1) return mkp(1,1);
if(N==2) return mkp(1,2);
if(N==3){
return in(1,2,3)?mkp(2,3):(in(2,1,3)?mkp(1,3):mkp(1,2));
}
int x=1,y=2,z=0,t=0;
std::vector<int> a(N+1,0);
int mx=0;
for(int i=1;i<=N;++i) if(i!=x&&i!=y){
a[i]=query(i,x,y);
if(!mx) mx=i;
else if(a[i]>a[mx]) mx=i;
}
y=mx;
//printf("%d %d %d %d\n",x,y,z,t);
a=std::vector<int>(N+1,0);
mx=0;
for(int i=1;i<=N;++i) if(i!=x&&i!=y){
a[i]=query(i,x,y);
if(!mx) mx=i;
else if(a[i]>a[mx]) mx=i;
}
z=mx;
//printf("%d %d %d %d\n",x,y,z,t);
a=std::vector<int>(N+1,0);
mx=0;
int mn=0;
for(int i=1;i<=N;++i) if(i!=z&&i!=y){
a[i]=query(i,z,y);
if(!mx) mx=mn=i;
else{
if(a[i]>a[mx]) mx=i;
if(a[i]<a[mn]) mn=i;
}
}
x=mx;
t=mn;
//printf("%d %d %d %d\n",x,y,z,t);
if(x==t) return mkp(y,z);
if(!in(t,y,z)){
if(query(x,t,z)>query(x,t,y)) return mkp(x,z);
else return mkp(x,y);
}
int dyz=a[t]/2,dxyz=a[x]/2;
int dyxt=query(y,x,t)/2;
int dzxt=query(x,t,z)/2;
int dxy,dxz;
if(!in(t,x,y)){
dxz=dzxt;
dxy=dxyz*2-dyz-dzxt;
}else{
dxy=dzxt;
dxz=dxyz*2-dyz-dyxt;
}
if(std::max({dyz,dxy,dxz})==dyz) return mkp(y,z);
if(std::max({dyz,dxy,dxz})==dxy) return mkp(x,y);
return mkp(x,z);
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 15100kb
input:
1 100 25 1 3 2 18 3 8 4 18 5 14 6 22 7 18 8 10 9 11 10 12 11 25 12 16 13 11 14 17 15 17 16 25 17 2 18 20 19 18 20 12 21 1 22 17 23 14 24 1 50 1 37 2 27 3 10 4 25 5 16 6 17 7 10 8 36 9 16 10 6 11 48 12 2 13 28 14 30 15 10 16 44 17 31 18 1 19 6 20 7 21 30 22 42 23 45 24 23 25 27 26 39 27 45 28 48 29 4...
output:
WA
result:
wrong answer Wrong Answer
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #6:
0%
Subtask #8:
score: 0
Skipped
Dependency #7:
0%
Subtask #9:
score: 0
Skipped
Dependency #8:
0%
Subtask #10:
score: 0
Skipped
Dependency #9:
0%
Subtask #11:
score: 0
Skipped
Dependency #1:
0%