QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#860370 | #9678. 网友小 Z 的树 | Physics212303 | 0 | 0ms | 14760kb | C++17 | 1.2kb | 2025-01-18 13:01:18 | 2025-01-18 13:01:19 |
Judging History
answer
#include "diameter.h"
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
mt19937 g(time(0));
pii find_diameter(int id,int n){
if(n==1)return make_pair(1,1);
if(n==2)return make_pair(1,2);
vector<int> p(n);
iota(p.begin(),p.end(),1);
shuffle(p.begin(),p.end(),g);
uniform_int_distribution<> U(1,n);
int u=U(g),v=U(g),w=U(g);
while(v==u)v=U(g);
while(w==u||w==v)w=U(g);
int c=query(u,v,w);
for(int i=0;i<p.size()>>1;i++)
if(p[i]!=u&&p[i]!=v&&p[i]!=w){
int r1=query(u,v,p[i]),r2=query(u,w,p[i]),mn=min({c,r1,r2});
if(mn==r1)w=p[i];
else if(mn==r2)v=p[i];
}
if(in(u,w,v))swap(u,w);
u=c=0;
for(int i=1;i<=n;i++)
if(i!=u&&i!=v&&i!=w){
int r=query(v,w,i);
if(r>c)c=r,u=i;
}
v=U(g),w=U(g);
while(v==u)v=U(g);
while(w==u||w==v)w=U(g);
c=query(u,v,w);
for(int i=0;i<p.size()>>1;i++)
if(p[i]!=u&&p[i]!=v&&p[i]!=w){
int r1=query(u,v,p[i]),r2=query(u,w,p[i]),mn=min({c,r1,r2});
if(mn==r1)w=p[i];
else if(mn==r2)v=p[i];
}
if(in(w,u,v))swap(w,v);
w=c=0;
for(int i=1;i<=n;i++)
if(i!=u&&i!=v&&i!=w){
int r=query(u,v,i);
if(r>c)c=r,w=i;
}
return make_pair(u,w);
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 14760kb
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%