답안 #120045

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120045 2019-06-23T06:16:12 Z Boxworld Pairs (IOI07_pairs) C++14
47 / 100
4000 ms 2140 KB
#include <bits/stdc++.h>
using namespace std;
const int N=100010;
struct point{int x,y,z;}a[N];
long long ans=0;
int B,n,d,m;
bool cmp(point a,point b){return a.x<b.x;}
void solve1(){
	for (int i=0;i<n;i++)scanf("%d",&a[i].x);
	sort(a,a+n,cmp);
	int tmp=0;
	for (int i=1;i<n;i++){
		while (a[i].x-a[tmp].x>d)tmp++;
		ans+=(i-tmp);
	}
}
double dist2(int x,int y,int X,int Y){return abs(X-x)+abs(Y-y);}
void solve2(){
	
	for (int i=0;i<n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
		for (int j=0;j<i;j++)
		if (dist2(a[i].x,a[i].y,a[j].x,a[j].y)<=d)ans++;
	}
}
double dist3(int x,int y,int z,int X,int Y,int Z){return abs(X-x)+abs(Y-y)+abs(Z-z);}
void solve3(){
	for (int i=0;i<n;i++){
		scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
		for (int j=0;j<i;j++)
		if (dist3(a[i].x,a[i].y,a[i].z,a[j].x,a[j].y,a[j].z)<=d)ans++;
	}
}
int main(){
	scanf("%d%d%d%d",&B,&n,&d,&m);
	if (B==1)solve1();
	if (B==2)solve2();
	if (B==3)solve3();
	printf("%lld\n",ans);
	return 0;
}

Compilation message

pairs.cpp: In function 'void solve1()':
pairs.cpp:9:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=0;i<n;i++)scanf("%d",&a[i].x);
                       ~~~~~^~~~~~~~~~~~~~
pairs.cpp: In function 'void solve2()':
pairs.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&a[i].x,&a[i].y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
pairs.cpp: In function 'void solve3()':
pairs.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pairs.cpp: In function 'int main()':
pairs.cpp:35:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d",&B,&n,&d,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 1664 KB Output is correct
2 Correct 20 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1664 KB Output is correct
2 Correct 28 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1656 KB Output is correct
2 Correct 26 ms 1656 KB Output is correct
3 Correct 25 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4085 ms 1684 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4011 ms 1812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4069 ms 2140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4008 ms 1508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4026 ms 1808 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4029 ms 1572 KB Time limit exceeded
2 Halted 0 ms 0 KB -