# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
704305 |
2023-03-02T03:20:24 Z |
bachhoangxuan |
Park (JOI17_park) |
C++17 |
|
148 ms |
724 KB |
#include<bits/stdc++.h>
#include "park.h"
using namespace std;
int n;
namespace sub1{
int place[255];
void solve(){
for(int i=0;i<n;i++){
place[i]=1;
for(int j=i+1;j<n;j++){
place[j]=1;
if(Ask(i,j,place)) Answer(i,j);
place[j]=0;
}
place[i]=0;
}
return;
}
}
namespace sub2{
int place[1405];
bool in(int u,int a){
if(a==0 || a==u) return true;
for(int i=0;i<n;i++) place[i]=(i!=a);
return !Ask(0,u,place);
}
void solve(){
vector<int> x={0,n-1};
for(int i=1;i<n-1;i++){
int lt=1,rt=(int)x.size()-1,res=1;
while(rt>=lt){
int mid=(lt+rt)>>1;
if(in(i,x[mid])) lt=mid+1;
else{res=mid;rt=mid-1;}
}
x.insert(x.begin()+res,i);
}
for(int i=0;i<n-1;i++) Answer(min(x[i],x[i+1]),max(x[i],x[i+1]));
}
}
namespace sub3{
int place[1405];
vector<int> child[1405];
void dfs(int u){
vector<int> nxt;
for(int i=0;i<n;i++) place[i]=0;
place[u]=1;
for(int x:child[u]){
place[x]=1;
if(Ask(min(u,x),max(u,x),place)){
Answer(min(u,x),max(u,x));
nxt.push_back(x);
}
place[x]=0;
}
place[u]=0;
for(int i=0;i<n;i++) place[i]=1;
for(int x:child[u]){
if(x==u) continue;
bool check=false;
for(int v:nxt) check|=(v==x);
if(check) continue;
int lt=1,rt=(int)nxt.size()-1,res=0;
while(rt>=lt){
int mid=(lt+rt)>>1;
for(int i=0;i<=mid;i++) place[nxt[i]]=0;
if(Ask(min(u,x),max(u,x),place)) lt=mid+1;
else{res=mid;rt=mid-1;}
for(int v:nxt) place[v]=1;
}
child[nxt[res]].push_back(x);
}
for(int v:nxt) dfs(v);
}
void solve(){
for(int i=1;i<n;i++) child[0].push_back(i);
dfs(0);
}
}
void Detect(int T, int N) {
n=N;
if(T==1) sub1::solve();
else if(T==2) sub2::solve();
else sub3::solve();
}
//g++ -std=c++14 -O2 -o grader grader.cpp park.cpp
/*
2
5
4
0 1
1 3
3 2
2 4
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
340 KB |
Output is correct |
3 |
Correct |
5 ms |
372 KB |
Output is correct |
4 |
Correct |
4 ms |
340 KB |
Output is correct |
5 |
Correct |
4 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
480 KB |
Output is correct |
2 |
Correct |
91 ms |
468 KB |
Output is correct |
3 |
Correct |
79 ms |
492 KB |
Output is correct |
4 |
Correct |
142 ms |
488 KB |
Output is correct |
5 |
Correct |
143 ms |
472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
42 ms |
688 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
24 ms |
664 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
724 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |