Submission #217947

# Submission time Handle Problem Language Result Execution time Memory
217947 2020-03-31T09:46:37 Z dorijanlendvaj Park (JOI17_park) C++14
77 / 100
188 ms 668 KB
#include "park.h"
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")
#define vi vector<int>
#define vl vector<ll>
#define all(a) begin(a),end(a)

using namespace std;
using ll=long long;
const char en='\n';

static int Place[1400];
int n,de[1400],par[1400];
vi im[1400],sv,cur;
bool bio[1400];

int rmq(int a,int b) //max
{
	int lo=-1,hi=n-1;
	while (lo<hi)
	{
		int mid=(lo+hi+2)/2-1;
		for (int i=0;i<=mid;++i) Place[i]=1;
		for (int i=mid+1;i<n;++i) Place[i]=0;
		Place[a]=1;
		Place[b]=1;
		if (Ask(min(a,b),max(a,b),Place)) hi=mid;
		else lo=mid+1;
	}
	return lo;
}

void cons(int l,int r)
{
	int a=rmq(l,r);
	if (a==-1) return;
	cons(l,a);
	cur.pb(a);
	cons(a,r);
}

mt19937 rng(177);

void Detect(int T, int N) {
	if (T==1)
	{
		for (int i=0;i<N;++i)
		{
			for (int j=i+1;j<N;++j)
			{
				Place[i]=Place[j]=1;
				if (Ask(i,j,Place)) Answer(i,j);
				Place[i]=Place[j]=0;
			}
		}
		return;
	}
	n=N;
	vi ord;
	for (int i=1;i<n;++i) ord.pb(i);
	shuffle(all(ord),rng);
	im[0].pb(0);
	bio[0]=1;
	sv.pb(0);
	int mad=0;
	for (auto i: ord)
	{
		if (bio[i]) continue;
		int lo=0,hi=mad;
		while (lo<hi)
		{
			int mid=(lo+hi+1)/2;
			for (int i=0;i<n;++i) Place[i]=1;
			for (auto a: sv) if (de[a]>=mid) Place[a]=0;
			if (Ask(0,i,Place)) hi=mid-1;
			else lo=mid;
		}
		int dd=lo;
		lo=0;
		hi=im[dd].size()-1;
		while (lo<hi)
		{
			int mid=(lo+hi)/2;
			for (int i=0;i<n;++i) Place[i]=1;
			for (int i=0;i<=mid;++i) Place[im[dd][i]]=0;
			if (Ask(0,i,Place)) lo=mid+1;
			else hi=mid;
		}
		int no=im[dd][lo];
		//cout<<i<<' '<<no<<endl;
		cur.clear();
		cur.pb(no);
		cons(no,i);
		cur.pb(i);
		for (int i=1;i<cur.size();++i)
		{
			par[cur[i]]=cur[i-1];
			de[cur[i]]=de[cur[i-1]]+1;
			im[de[cur[i]]].pb(cur[i]);
			bio[cur[i]]=1;
			sv.pb(cur[i]);
			mad=max(mad,de[cur[i]]);
			//cout<<cur[i]<<' '<<par[cur[i]]<<' '<<de[cur[i]]<<endl;
			Answer(min(cur[i-1],cur[i]),max(cur[i-1],cur[i]));
		}
	}
}

Compilation message

park.cpp: In function 'void Detect(int, int)':
park.cpp:100:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i=1;i<cur.size();++i)
                ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 10 ms 384 KB Output is correct
3 Correct 9 ms 436 KB Output is correct
4 Correct 10 ms 384 KB Output is correct
5 Correct 10 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 576 KB Output is correct
2 Correct 118 ms 608 KB Output is correct
3 Correct 98 ms 632 KB Output is correct
4 Correct 50 ms 512 KB Output is correct
5 Correct 49 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 170 ms 632 KB Output is correct
2 Correct 181 ms 536 KB Output is correct
3 Correct 170 ms 408 KB Output is correct
4 Correct 169 ms 512 KB Output is correct
5 Correct 188 ms 512 KB Output is correct
6 Correct 170 ms 512 KB Output is correct
7 Correct 177 ms 512 KB Output is correct
8 Correct 174 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 512 KB Output is correct
2 Correct 133 ms 576 KB Output is correct
3 Correct 135 ms 512 KB Output is correct
4 Correct 125 ms 512 KB Output is correct
5 Correct 125 ms 588 KB Output is correct
6 Correct 101 ms 512 KB Output is correct
7 Correct 73 ms 512 KB Output is correct
8 Correct 126 ms 544 KB Output is correct
9 Correct 123 ms 536 KB Output is correct
10 Correct 148 ms 572 KB Output is correct
11 Correct 139 ms 512 KB Output is correct
12 Correct 164 ms 660 KB Output is correct
13 Correct 79 ms 668 KB Output is correct
14 Correct 179 ms 592 KB Output is correct
15 Correct 72 ms 512 KB Output is correct
16 Correct 175 ms 384 KB Output is correct
17 Correct 46 ms 512 KB Output is correct
18 Correct 154 ms 512 KB Output is correct
19 Correct 67 ms 512 KB Output is correct
20 Correct 117 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 512 KB Wrong Answer[3]
2 Halted 0 ms 0 KB -