# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
60649 |
2018-07-24T13:08:29 Z |
Diuven |
Park (JOI17_park) |
C++11 |
|
86 ms |
25928 KB |
#include "park.h"
#include <vector>
#include <algorithm>
#include <iostream>
#include <utility>
#include <assert.h>
#include <map>
using namespace std;
typedef pair<int, int> pii;
static int full[1400], empt[1400];
int n;
void add_edge(int x, int y){
if(x>y) swap(x,y);
assert(x!=y);
Answer(x,y);
}
int my_ask(int a, int b, int Arr[]){
if(a>b) swap(a,b);
// cout<<a<<' '<<b<<'\n';
assert(a!=b && Arr[a] && Arr[b]);
return Ask(a,b,Arr);
}
void solve1(){
int P[250]={};
for(int i=0; i<n; i++)
for(int j=i+1; j<n; j++){
P[i]=P[j]=1;
if(my_ask(i,j,P)) Answer(i,j);
P[i]=P[j]=0;
}
}
vector<int> G[1400];
int nu[1400], now;
bool done[1400];
void fill_line(int u, int v){
// cout<<u<<' '<<v<<'\n';
int Arr[1400]={};
Arr[u]=Arr[v]=1;
if(my_ask(u,v,Arr)){
add_edge(u,v);
G[u].push_back(v);
G[v].push_back(u);
return;
}
vector<int> W;
for(int i=0; i<n; i++) if(!done[i]) W.push_back(i);
int s=0, e=W.size()-1;
while(s<e){
int m=(s+e)/2;
for(int i=0; i<=m; i++) Arr[W[i]]=1;
int res=my_ask(u, v, Arr);
for(int i=0; i<=m; i++) Arr[W[i]]=0;
if(res) e=m;
else s=m+1;
}
done[W[s]]=true;
fill_line(u, W[s]);
fill_line(W[s], v);
}
void dfs(int v, int p=-1){
nu[v]=++now;
for(int x:G[v]) if(x!=p) dfs(x,v);
}
void solve2(){
done[0]=true;
for(int i=1; i<n; i++){
if(done[i]) continue;
vector<int> V;
for(int i=0; i<n; i++) if(done[i]) V.push_back(i);
int Arr[1400]={};
for(int j=0; j<n; j++) Arr[j]=!done[j];
now=0; dfs(V[0], -1);
int s=0, e=V.size()-1U;
while(s<e){
int m=(s+e)/2;
for(int j=0; j<=m; j++) Arr[V[j]]=1;
int res=my_ask(V[m], i, Arr);
for(int j=0; j<=m; j++) Arr[V[j]]=0;
if(res) e=m;
else s=m+1;
}
// for(int i=0; i<n; i++) cout<<done[i]<<' ';
// cout<<'\n';
done[i]=true;
fill_line(V[s], i);
}
}
void Detect(int T, int _n) {
n=_n;
for(int i=0; i<n; i++) full[i]=1;
if(T==1) solve1();
if(2<=T && T<=4) solve2();
}
Compilation message
park.cpp:11:24: warning: 'empt' defined but not used [-Wunused-variable]
static int full[1400], empt[1400];
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
12 ms |
556 KB |
Output is correct |
3 |
Correct |
10 ms |
556 KB |
Output is correct |
4 |
Correct |
12 ms |
556 KB |
Output is correct |
5 |
Correct |
11 ms |
556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
63 ms |
15972 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
86 ms |
25928 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
49 ms |
25928 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
25928 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |