QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#66421 | #5015. 树 | crazy_sea | Compile Error | / | / | C++14 | 1.5kb | 2022-12-08 12:25:20 | 2022-12-08 12:25:25 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-12-08 12:25:25]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-12-08 12:25:20]
- 提交
answer
#include<cstdio>
#include<vector>
#include<ctime>
#include<algorithm>
#define vi vector<int>
using namespace std;
const int N=1e3+10;
int lca[N][12],dep[N],f[N];
mt19937 rnd;
int t[N*N];
void init(int x,int y)
{
lca[x][0]=y;
for(int i=1;i<=10;i++)
lca[x][i]=lca[lca[x][i-1]][i-1];
answer(x,y);
}
int get_dis(int x,int y)
{
int s=dep[x]+dep[y];
if(dep[x]<dep[y]) swap(x,y);
for(int i=10;i>=0;i--)
if(dep[lca[x][i]]>=dep[y]) x=lca[x][i];
for(int i=10;i>=0;i--)
if(lca[x][i]!=lca[y][i])
x=lca[x][i],y=lca[y][i];
if(x!=y) x=lca[x][0];
return s-2*dep[x];
}
void solve(vi A,vi B)
{
int m=A.size(),n=B.size(),cnt=0;
if(m==0) return;
if(n==1)
{
for(int x:A) init(x,B[0]);
return;
}
else if(n==2)
{
vi v(1);
v[0]=B[0];
for(int x:A) if(ask(x,v)==1) init(x,v[0]);
else init(x,B[1]);
return;
}
vi v1(n/2);
for(int i=1;i<m;i++) swap(A[i],A[rnd()%(i+1)]);
for(int i=0;i<n/2;i++) v1[i]=B[i];
for(int x:B) f[x]=v1.size();
for(int x:B) for(int y:v1) f[x]+=get_dis(x,y);
for(int x:B)
if(!t[f[x]]) t[f[x]]=++cnt;
vector<vi> v(cnt),a(cnt);
for(int x:B) v[t[f[x]]-1].push_back(x);
for(int x:A) a[t[ask(x,v1)]-1].push_back(x);
for(int x:B) t[f[x]]=0;
for(int i=0;i<cnt;i++) solve(a[i],v[i]);
}
vi v[N];
void solver(int n,int A,int B)
{
int rt=rnd()%n+1;
vi s(1);
for(int i=1;i<=n;i++)
{
if(i==rt) continue;
s[0]=i,dep[i]=ask(rt,s);
v[dep[i]].push_back(i);
}
for(int x:v[1]) init(x,rt);
for(int i=2;i<=n;i++)
{
if(v[i].empty()) break;
solve(v[i],v[i-1]);
}
}
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:9:1: error: ‘mt19937’ does not name a type 9 | mt19937 rnd; | ^~~~~~~ answer.code: In function ‘void init(int, int)’: answer.code:16:9: error: ‘answer’ was not declared in this scope 16 | answer(x,y); | ^~~~~~ answer.code: In function ‘void solve(std::vector<int>, std::vector<int>)’: answer.code:43:33: error: ‘ask’ was not declared in this scope 43 | for(int x:A) if(ask(x,v)==1) init(x,v[0]); | ^~~ answer.code:48:42: error: ‘rnd’ was not declared in this scope; did you mean ‘rand’? 48 | for(int i=1;i<m;i++) swap(A[i],A[rnd()%(i+1)]); | ^~~ | rand answer.code:56:26: error: ‘ask’ was not declared in this scope 56 | for(int x:A) a[t[ask(x,v1)]-1].push_back(x); | ^~~ answer.code: In function ‘void solver(int, int, int)’: answer.code:63:16: error: ‘rnd’ was not declared in this scope; did you mean ‘rand’? 63 | int rt=rnd()%n+1; | ^~~ | rand answer.code:68:31: error: ‘ask’ was not declared in this scope 68 | s[0]=i,dep[i]=ask(rt,s); | ^~~