# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
107097 |
2019-04-21T23:42:58 Z |
thebes |
Park (JOI17_park) |
C++14 |
|
172 ms |
636 KB |
#include <bits/stdc++.h>
#include "park.h"
using namespace std;
int *arr;
bool cmp(int i,int j){
int heh;
arr[i]=0;
if(Ask(0,j,arr)) heh = 0;
else heh = 1;
arr[i]=1;
return heh;
}
void Detect(int T, int N){
arr = (int*)malloc(N*sizeof(int));
if(T==1){
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++){
arr[i]=arr[j]=1;
if(Ask(i,j,arr)) Answer(i,j);
arr[i]=arr[j]=0;
}
}
}
else if(T==2){
for(int i=0;i<N;i++) arr[i]=1;
int lol[2000];
for(int i=1;i<N-1;i++) lol[i-1]=i;
sort(lol,lol+N-2,cmp);
Answer(0,lol[0]);
for(int i=0;i<N-3;i++) Answer(min(lol[i],lol[i+1]),max(lol[i],lol[i+1]));
Answer(lol[N-3],N-1);
}
else if(T==3){
int mrk[2000], par[2000];
memset(mrk,0,sizeof(mrk));
memset(par,0,sizeof(par));
mrk[0] = 1; par[0] = -1;
vector<int> a, b;
a.push_back(0);
for(int i=0;i<N;i++) arr[i]=0;
for(int i=1;i<N;i++){
arr[i]=1; arr[0]=1;
if(Ask(0,i,arr)){
mrk[i]=1; par[i]=0;
b.push_back(i);
}
arr[i]=0; arr[0]=0;
}
swap(a,b);
while(1){
for(auto v : b) arr[v]=1;
b.clear(); int lol = 0;
for(int i=0;i<N;i++){
if(mrk[i]) continue;
lol = 1;
int lo=0, hi=a.size();
while(lo<hi){
int m = lo+hi>>1;
for(int i=0;i<=m;i++){
arr[a[i]]=1;
}
arr[i]=1;
if(Ask(0,i,arr)) hi=m;
else lo=m+1;
arr[i]=0;
for(int i=0;i<=m;i++){
arr[a[i]]=0;
}
}
if(lo!=a.size()){
par[i]=a[lo];
b.push_back(i);
mrk[i]=1;
}
}
swap(a,b);
if(!lol) break;
}
for(int i=1;i<N;i++){
Answer(min(par[i],i),max(par[i],i));
}
}
}
Compilation message
park.cpp: In function 'void Detect(int, int)':
park.cpp:60:31: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int m = lo+hi>>1;
~~^~~
park.cpp:72:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(lo!=a.size()){
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
384 KB |
Output is correct |
3 |
Correct |
7 ms |
384 KB |
Output is correct |
4 |
Correct |
9 ms |
512 KB |
Output is correct |
5 |
Correct |
8 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
149 ms |
532 KB |
Output is correct |
2 |
Correct |
107 ms |
384 KB |
Output is correct |
3 |
Correct |
119 ms |
604 KB |
Output is correct |
4 |
Correct |
149 ms |
504 KB |
Output is correct |
5 |
Correct |
172 ms |
580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
134 ms |
384 KB |
Output is correct |
2 |
Correct |
167 ms |
632 KB |
Output is correct |
3 |
Correct |
146 ms |
384 KB |
Output is correct |
4 |
Correct |
87 ms |
636 KB |
Output is correct |
5 |
Correct |
142 ms |
384 KB |
Output is correct |
6 |
Incorrect |
129 ms |
504 KB |
Wrong Answer[5] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Wrong Answer[6] |
2 |
Halted |
0 ms |
0 KB |
- |