QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#859666 | #9678. 网友小 Z 的树 | rqoi031 | 0 | 1ms | 10176kb | C++20 | 1.7kb | 2025-01-17 21:34:17 | 2025-01-17 21:34:44 |
Judging History
answer
#include"diameter.h"
#include<stdio.h>
#include<algorithm>
#include<utility>
#include<tuple>
std::pair<int,int> find_diameter(int task_id,int n) {
if(n==1) {
return {1,1};
}
if(n==2) {
return {1,2};
}
if(n==3) {
if(in(1,2,3)) {
return {2,3};
}
if(in(2,1,3)) {
return {1,3};
}
return {1,2};
}
const auto find([&](const int &x,const int &y)->std::tuple<std::tuple<int,int>,std::tuple<int,int>> {
std::tuple<int,int> min(1000000000,0),max(-1000000000,0);
for(int i=1;i<=n;i++) {
if(i==x||i==y) {
continue;
}
std::tuple<int,int> tmp(query(x,y,i),i);
min=std::min(min,tmp);
max=std::max(max,tmp);
}
return {min,max};
});
int a{std::get<1>(std::get<1>(find(1,2)))};
int b{std::get<1>(std::get<1>(find(1,a)))};
auto [r0,r1](find(a,b));
fprintf(stderr,"a = %d, b = %d\n",a,b);
auto &[d0,x](r0);
auto &[s,c](r1);
fprintf(stderr,"x = %d\n",x);
fprintf(stderr,"c = %d\n",c);
if(x==c) {
return {a,b};
}
int d1{},d2{};
if(in(x,a,b)) {
if(in(x,a,c)) {
d1=query(x,a,c),d2=s-d0-d1;
}
else {
d2=query(x,b,c),d1=s-d0-d2;
}
}
else {
d0=1;
if(in(b,a,c)) {
d1=query(b,a,c),d2=s-d0-d1;
}
else {
d2=query(a,b,c),d1=s-d0-d2;
}
}
if(d0>=d1&&d0>=d2) {
return {a,b};
}
if(d1>=d2) {
return {a,c};
}
return {b,c};
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 10176kb
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%