QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#859892 | #9678. 网友小 Z 的树 | tebiezhichu | 16 | 17ms | 16012kb | C++14 | 4.0kb | 2025-01-18 08:04:34 | 2025-01-18 08:04:35 |
Judging History
answer
#include "diameter.h"
#include<bits/stdc++.h>
using namespace std;
long long yi[10][10]={
{2,2,-1,-1,2,-1,-1,-1,-1,2},
{2,-1,2,-1,-1,2,-1,-1,2,-1},
{2,-1,-1,2,-1,-1,2,2,-1,-1},
{-1,2,2,-1,-1,-1,2,2,-1,-1},
{-1,2,-1,2,-1,2,-1,-1,2,-1},
{-1,-1,2,2,2,-1,-1,-1,-1,2},
{-1,-1,-1,2,2,2,-1,2,-1,-1},
{-1,-1,2,-1,2,-1,2,-1,2,-1},
{-1,2,-1,-1,-1,2,2,-1,-1,2},
{2,-1,-1,-1,-1,-1,-1,2,2,2},
};
long long vis[5],dian[10],x[10],y[10],mu,zhi1,zhi2,op,mx;
std::pair<int, int> find_diameter(int subid, int n){
if(n==2){
return {1,2};
}
if(n==3){
if(in(1,2,3)){
return {2,3};
}
else if(in(2,1,3)){
return {1,3};
}
else{
return {1,2};
}
}
if(n==4){
vis[1]=1;
vis[2]=1;
vis[3]=1;
vis[4]=1;
if(query(1,2,3)==6){
vis[4]=0;
}
if(query(1,2,4)==6){
vis[3]=0;
}
if(query(1,3,4)==6){
vis[2]=0;
}
if(query(2,3,4)==6){
vis[1]=0;
}
if(vis[1]&&vis[2]){
return {1,2};
}
if(vis[1]&&vis[3]){
return {1,3};
}
if(vis[1]&&vis[4]){
return {1,4};
}
if(vis[2]&&vis[3]){
return {2,3};
}
if(vis[2]&&vis[4]){
return {2,4};
}
if(vis[3]&&vis[4]){
return {3,4};
}
}
mu=5;
dian[1]=1;
dian[2]=2;
dian[3]=3;
dian[4]=4;
dian[5]=5;
op=0;
y[0]=query(dian[1],dian[2],dian[3]);
y[1]=query(dian[1],dian[2],dian[4]);
y[2]=query(dian[1],dian[2],dian[5]);
y[3]=query(dian[1],dian[3],dian[4]);
y[4]=query(dian[1],dian[3],dian[5]);
y[5]=query(dian[1],dian[4],dian[5]);
y[6]=query(dian[2],dian[3],dian[4]);
y[7]=query(dian[2],dian[3],dian[5]);
y[8]=query(dian[2],dian[4],dian[5]);
y[9]=query(dian[3],dian[4],dian[5]);
for(int i=0;i<=9;i++){
x[i]=0;
for(int j=0;j<=9;j++){
x[i]=x[i]+yi[j][i]*y[j];
}
x[i]/=6;
}
mx=0;
if(x[0]>mx){
mx=x[0];
zhi1=dian[1];
zhi2=dian[2];
}
if(x[1]>mx){
mx=x[1];
zhi1=dian[1];
zhi2=dian[3];
}
if(x[2]>mx){
mx=x[2];
zhi1=dian[1];
zhi2=dian[4];
}
if(x[3]>mx){
mx=x[3];
zhi1=dian[1];
zhi2=dian[5];
}
if(x[4]>mx){
mx=x[4];
zhi1=dian[2];
zhi2=dian[3];
}
if(x[5]>mx){
mx=x[5];
zhi1=dian[2];
zhi2=dian[4];
}
if(x[6]>mx){
mx=x[6];
zhi1=dian[2];
zhi2=dian[5];
}
if(x[7]>mx){
mx=x[7];
zhi1=dian[3];
zhi2=dian[4];
}
if(x[8]>mx){
mx=x[8];
zhi1=dian[3];
zhi2=dian[5];
}
if(x[9]>mx){
mx=x[9];
zhi1=dian[4];
zhi2=dian[5];
}
op=1;
while(mu<n){
mu+=3;
dian[1]=zhi1;
dian[2]=zhi2;
x[0]=mx;
dian[3]=mu-2;
dian[4]=mu-1;
dian[5]=mu;
while(dian[5]>n||dian[5]==dian[1]||dian[5]==dian[2]||dian[5]==dian[3]||dian[5]==dian[4]){
dian[5]=rand()*998244353ll%n+1;
}
while(dian[4]>n||dian[4]==dian[1]||dian[4]==dian[2]||dian[4]==dian[3]||dian[4]==dian[5]){
dian[4]=rand()*998244353ll%n+1;
}
y[1]=query(dian[1],dian[2],dian[4]);
y[2]=query(dian[1],dian[2],dian[5]);
y[3]=query(dian[1],dian[3],dian[4]);
y[4]=query(dian[1],dian[3],dian[5]);
y[5]=query(dian[1],dian[4],dian[5]);
y[6]=query(dian[2],dian[3],dian[4]);
y[7]=query(dian[2],dian[3],dian[5]);
y[8]=query(dian[2],dian[4],dian[5]);
y[9]=query(dian[3],dian[4],dian[5]);
y[0]=3*x[0]-y[1]-y[2]-y[9]+(y[3]+y[4]+y[5]+y[6]+y[7]+y[8])/2;
for(int i=0;i<=9;i++){
x[i]=0;
for(int j=0;j<=9;j++){
x[i]=x[i]+yi[j][i]*y[j];
}
x[i]/=6;
}
mx=0;
if(x[0]>mx){
mx=x[0];
zhi1=dian[1];
zhi2=dian[2];
}
if(x[1]>mx){
mx=x[1];
zhi1=dian[1];
zhi2=dian[3];
}
if(x[2]>mx){
mx=x[2];
zhi1=dian[1];
zhi2=dian[4];
}
if(x[3]>mx){
mx=x[3];
zhi1=dian[1];
zhi2=dian[5];
}
if(x[4]>mx){
mx=x[4];
zhi1=dian[2];
zhi2=dian[3];
}
if(x[5]>mx){
mx=x[5];
zhi1=dian[2];
zhi2=dian[4];
}
if(x[6]>mx){
mx=x[6];
zhi1=dian[2];
zhi2=dian[5];
}
if(x[7]>mx){
mx=x[7];
zhi1=dian[3];
zhi2=dian[4];
}
if(x[8]>mx){
mx=x[8];
zhi1=dian[3];
zhi2=dian[5];
}
if(x[9]>mx){
mx=x[9];
zhi1=dian[4];
zhi2=dian[5];
}
}
return {zhi1,zhi2};
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 16
Accepted
Test #1:
score: 16
Accepted
time: 3ms
memory: 14216kb
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:
correct
result:
ok Correct
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #2:
score: 0
Wrong Answer
time: 17ms
memory: 16012kb
input:
2 2006 42 1 32 2 4 3 6 4 29 5 1 6 42 7 10 8 16 9 6 10 25 11 42 12 8 13 36 14 8 15 17 16 3 17 6 18 21 19 23 20 31 21 42 22 6 23 32 24 7 25 27 26 34 27 31 28 6 29 41 30 20 31 9 32 7 33 3 34 5 35 5 36 1 37 8 38 14 39 15 40 12 41 22 95 1 94 2 88 3 13 4 71 5 37 6 45 7 87 8 24 9 76 10 54 11 69 12 95 13 90...
output:
WA
result:
wrong answer Wrong Answer
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:
100%
Accepted
Dependency #2:
0%