QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#799029 | #63. Meetings | SimonLJK | 0 | 3ms | 3988kb | C++14 | 1.1kb | 2024-12-04 20:42:56 | 2024-12-04 20:43:03 |
answer
#include "meetings.h"
#include<bits/stdc++.h>
using namespace std;
mt19937 rd(14685413);
vector<int> b[2009];
void solve(int rt,vector<int> vec){
b[rt].clear();
if(!vec.size()) return;
if(vec.size()==1){ Bridge(rt,vec[0]); return; }
random_shuffle(vec.begin(),vec.end());
int nd=vec.back(); vec.pop_back();
vector<int> sta;
int v,w;
for(int i=0;i<vec.size();i++){
v=vec[i]; w=Query(rt,nd,v);
if(w==v){ sta.push_back(v); }
else{ b[w].push_back(v); }
}
int l,r,mid,re;
for(int i=1;i<sta.size();i++){
l=0,r=i-1,re=i;
while(l<=r){
mid=(l+r)/2;
if(Query(rt,sta[mid],sta[i])==sta[i]) re=mid,l=mid-1;
else r=mid+1;
}
for(int j=i;j>re;j--)
swap(sta[j],sta[j-1]);
}
for(int i=1;i<sta.size();i++)
Bridge(sta[i-1],sta[i]);
if(!sta.empty())
Bridge(rt,sta[0]),Bridge(sta.back(),nd);
else Bridge(rt,nd);
for(int i=0;i<sta.size();i++)
solve(sta[i],b[sta[i]]);
solve(rt,b[rt]); solve(nd,b[nd]);
return;
}
void Solve(int N){
int rt=rd()%N;
for(int i=0;i<N;i++)
if(i!=rt)
b[rt].push_back(i);
solve(rt,b[rt]);
return;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 7
Accepted
time: 0ms
memory: 3872kb
input:
3 0 2 0 1
output:
Accepted: 1
result:
ok 1 move(s)
Test #2:
score: 0
Wrong Answer
time: 3ms
memory: 3988kb
input:
4 1 2 0 2 0 3
output:
Wrong Answer [2]
result:
wrong answer
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%