Submission #181482


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]);
	}//return 0;
	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 1657 Byte
Status WA
Exec Time 1037 ms
Memory 4908 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 70 ms 2468 KB
02 WA 24 ms 2344 KB
03 WA 25 ms 2272 KB
04 WA 28 ms 2472 KB
05 WA 82 ms 2468 KB
06 WA 24 ms 2344 KB
07 TLE 1031 ms 3108 KB
08 TLE 1037 ms 3612 KB
09 WA 24 ms 2340 KB
10 WA 43 ms 2464 KB
11 TLE 1031 ms 4136 KB
12 TLE 1029 ms 4064 KB
13 TLE 1030 ms 3880 KB
14 TLE 1029 ms 4600 KB
15 TLE 1030 ms 4904 KB
16 WA 30 ms 2476 KB
17 TLE 1030 ms 4908 KB
18 WA 605 ms 2852 KB
19 WA 62 ms 2932 KB
20 WA 110 ms 3240 KB