QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#113174 | #5015. 树 | lgvc# | Compile Error | / | / | C++23 | 1.7kb | 2023-06-16 16:37:20 | 2024-05-31 14:01:53 |
Judging History
This is the latest submission verdict.
- [2024-05-31 14:01:53]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 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 16:37:20]
- Submitted
answer
#include "tree.h"
int dep[1009],siz[1009];
std::vector<int> qr(std::vector<int> a,int n,bool f) {
if(!f) {
int as=ask(n,a),aq=0;
for(int i=0;i<a.size();i++) aq+=dep[a[i]]-dep[n];
if(aq==as) return a;
int sz=a.size()/2;
std::vector<int> b,c,d;
if(a.size()==1) return b;
if(as==aq+2*a.size()) return b;
}
while(a.size()>sz) {
b.push_back(a.back());
a.pop_back();
}
c=qr(a,n,0);
d=qr(b,n,0);
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];
memset(v,0,sizeof(v));
for(int i=0;i+1<tp.size();i++) {
std::vector<int> ans;
ans=qr(xk,tp[i],1);
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) {
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 ‘std::vector<int> qr(std::vector<int>, int, bool)’: answer.code:13:24: error: ‘sz’ was not declared in this scope; did you mean ‘siz’? 13 | while(a.size()>sz) { | ^~ | siz answer.code:14:17: error: ‘b’ was not declared in this scope 14 | b.push_back(a.back()); | ^ answer.code:17:9: error: ‘c’ was not declared in this scope 17 | c=qr(a,n,0); | ^ answer.code:18:9: error: ‘d’ was not declared in this scope 18 | d=qr(b,n,0); | ^ answer.code:18:14: error: ‘b’ was not declared in this scope 18 | d=qr(b,n,0); | ^