# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
704309 |
2023-03-02T03:23:54 Z |
bachhoangxuan |
Park (JOI17_park) |
C++17 |
|
181 ms |
492 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;
}
if(nxt.empty()) return;
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 |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
7 ms |
364 KB |
Output is correct |
3 |
Correct |
7 ms |
340 KB |
Output is correct |
4 |
Correct |
7 ms |
340 KB |
Output is correct |
5 |
Correct |
11 ms |
368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
164 ms |
492 KB |
Output is correct |
2 |
Correct |
83 ms |
484 KB |
Output is correct |
3 |
Correct |
86 ms |
492 KB |
Output is correct |
4 |
Correct |
161 ms |
488 KB |
Output is correct |
5 |
Correct |
181 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
145 ms |
432 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
424 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
436 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |