Submission #181484


Source Code Expand

#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;

int n,t;
int zax[20005],zay[20005];
vector<int>seg[1<<16];
void update(int k,int x)
{
	k += (1<<15)-1;
	seg[k].push_back(x);
}
void update2()
{
	for(int k=(1<<15)-2;k>=0;k--)
	{
		seg[k].resize(seg[k*2+1].size()+seg[k*2+2].size());
		merge(seg[k*2+1].begin(),seg[k*2+1].end(),seg[k*2+2].begin(),seg[k*2+2].end(),seg[k].begin());
	}
}
int query(int k,int l,int r,int ax,int bx,int ay,int by)
{
	if(bx < l || r < ax) return 0;
	if(ax <= l && r <= bx)
	{
		return upper_bound(seg[k].begin(),seg[k].end(),by)-lower_bound(seg[k].begin(),seg[k].end(),ay);
	}
	int x = query(k*2+1,l,(l+r)/2,ax,bx,ay,by);
	int y = query(k*2+2,(l+r)/2+1,r,ax,bx,ay,by);
	return x+y;
}

int main()
{
	scanf("%d %d",&n,&t);
	vector<int>x,y;
	for(int i=0;i<n;i++)
	{
		scanf("%d %d",&zax[i],&zay[i]);
		x.push_back(zax[i]);
		y.push_back(zay[i]);
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	for(int i=0;i<n;i++)
	{
		zax[i] = lower_bound(x.begin(),x.end(),zax[i])-x.begin();
		zay[i] = lower_bound(y.begin(),y.end(),zay[i])-y.begin();
		update(zax[i],zay[i]);
	}
	update2();
	int res = 1e9;
	int l,r;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(abs(zax[i]-zax[j]) >= t-1 && abs(zay[i]-zay[j]) >= t-1)
			{
				int ex = query(0,0,(1<<15)-1,min(zax[i],zax[j]),max(zax[i],zax[j]),min(zay[i],zay[j]),max(zay[i],zay[j]));
				if(res > ex)
				{
					res = ex;
					l = i; r = j;
				}
				if(res == t)
				{
					printf("%d %d\n",++l,++r);
					return 0;
				}
			}
		}
	}
	printf("%d %d\n",++l,++r);
}

Submission Info

Submission Time
Task 2 - Artemis
User IH19980412
Language C++ (G++ 4.6.4)
Score 0
Code Size 1654 Byte
Status WA
Exec Time 1031 ms
Memory 4984 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:37:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:41:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

Judge Result

Set Name Set01 Set02 Set03 Set04 Set05 Set06 Set07 Set08 Set09 Set10 Set11 Set12 Set13 Set14 Set15 Set16 Set17 Set18 Set19 Set20
Score / Max Score 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5
Status
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
TLE × 1
TLE × 1
WA × 1
WA × 1
TLE × 1
TLE × 1
TLE × 1
TLE × 1
TLE × 1
WA × 1
TLE × 1
WA × 1
WA × 1
WA × 1
Set Name Test Cases
Set01 01
Set02 02
Set03 03
Set04 04
Set05 05
Set06 06
Set07 07
Set08 08
Set09 09
Set10 10
Set11 11
Set12 12
Set13 13
Set14 14
Set15 15
Set16 16
Set17 17
Set18 18
Set19 19
Set20 20
Case Name Status Exec Time Memory
01 WA 71 ms 2468 KB
02 WA 25 ms 2336 KB
03 WA 27 ms 2472 KB
04 WA 29 ms 2272 KB
05 WA 83 ms 2344 KB
06 WA 25 ms 2336 KB
07 TLE 1031 ms 3116 KB
08 TLE 1030 ms 3628 KB
09 WA 27 ms 2420 KB
10 WA 45 ms 2404 KB
11 TLE 1031 ms 4084 KB
12 TLE 1030 ms 4128 KB
13 TLE 1030 ms 3948 KB
14 TLE 1031 ms 4512 KB
15 TLE 1030 ms 4900 KB
16 WA 33 ms 2476 KB
17 TLE 1031 ms 4984 KB
18 WA 610 ms 2856 KB
19 WA 62 ms 2852 KB
20 WA 113 ms 3296 KB