QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#113190 | #5015. 树 | lgvc# | Compile Error | / | / | C++23 | 2.1kb | 2023-06-16 17:17:26 | 2024-05-31 14:02:07 |
Judging History
你现在查看的是最新测评结果
- [2024-05-31 14:02:07]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-06-16 17:17:26]
- 提交
answer
#include "tree.h"
int dep[1009],siz[1009];
std::vector<int> qr(std::vector<int> a,int n,bool f,int& tp) {
int as=0,aq=0;
if(!f) {
if(tp==-1) as=ask(n,a);else as=tp;
tp=as;
for(int i=0;i<a.size();i++) aq+=dep[a[i]]-dep[n];
if(aq==as) return a;
std::vector<int> tt;
if(a.size()==1) return tt;
if(as==aq+2*a.size()) return tt;
}
int sz=a.size()/2;
std::vector<int> b,c,d;
while(a.size()>sz) {
b.push_back(a.back());
a.pop_back();
}
int tpp=-1;
c=qr(a,n,0,tpp);
if(!f) {
tpp=as-tpp;
d=qr(b,n,0,tpp);
} else {
tpp=-1;
d=qr(b,n,0,tpp);
}
for(int i=0;i<d.size();i++) c.push_back(d[i]);
return c;
}
inline bool cmp(int a,int b) {
return siz[a]<siz[b];
}
void sv(int id,std::vector<int> qq) {
int su=0;
if(qq.size()==1) return;
for(int i=0;i<siz[id];i++) {
su+=dep[qq[i]]-dep[id];
}
std::vector<int> tp;
for(int i=0;i<siz[id];i++) {
if(dep[qq[i]]==dep[id]+1) {
tp.push_back(qq[i]);
answer(id,qq[i]);
}
}
std::vector<int> xk;
for(int i=0;i<qq.size();i++) if(qq[i]!=id) xk.push_back(qq[i]);
if(tp.size()==1) {
siz[tp[0]]=siz[id]-1;
sv(tp[0],xk);
return;
}
int l=siz[id]-1,son=0;
for(int i=0;i+1<tp.size();i++) {
int nm=ask(tp[i],qq);
siz[tp[i]]=(su-nm+siz[id])/2;
l-=siz[tp[i]];
}
siz[tp[tp.size()-1]]=l;
std::sort(tp.begin(),tp.end(),cmp);
bool v[1009];
int tpt=-1;
memset(v,0,sizeof(v));
for(int i=0;i+1<tp.size();i++) {
std::vector<int> ans;
tpt=-1;
ans=qr(xk,tp[i],1,tpt);
sv(tp[i],ans);
for(int j=0;j<ans.size();j++) v[ans[j]]=1;
}
std::vector<int> tpp;
for(int i=0;i<xk.size();i++) if(!v[xk[i]]) tpp.push_back(xk[i]);
sv(tp[tp.size()-1],tpp);
}
void solver(int N,int A,int B) {
if(A==500000) {
for(int i=1;i<=N;i++) {
for(int j=i+1;j<=N;j++) {
std::vector<int> qq;
qq.push(j);
if(ask(i,qq)==1) answer(i,j);
}
}
return;
}
for(int i=2;i<=N;i++) {
std::vector<int> qq;
qq.push_back(i);
dep[i]=ask(1,qq);
}
std::vector<int> qq;
for(int i=1;i<=N;i++) {
qq.push_back(i);
}
siz[1]=N;
sv(1,qq);
}
Details
implementer.cpp: In function ‘void regduj260135279::init()’: implementer.cpp:32:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%d",&n); | ~~~~~^~~~~~~~~ implementer.cpp:45:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 45 | scanf("%d%d",&u,&v); | ~~~~~^~~~~~~~~~~~~~ answer.code: In function ‘void solver(int, int, int)’: answer.code:82:36: error: ‘class std::vector<int>’ has no member named ‘push’ 82 | qq.push(j); | ^~~~