답안 #137535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137535 2019-07-28T06:17:24 Z 김현수(#3360) Countries (BOI06_countries) C++14
10 / 100
5 ms 376 KB
#include<bits/stdc++.h>
using namespace std;

const int N = 1005;

int n, x[N], y[N], s[N], c[N], d[N];

int sq (int X) {return X*X;}

int dist (int A, int B) {
	return sq(x[A]-x[B]) + sq(y[A]-y[B]);
}

int cmp (int X, int A, int B) {
	int V1 = s[A] * dist(X, B), V2 = s[B] * dist(X, A);
	return (V1 == V2 ? 0 : V1 > V2 ? -1 : 1);
}

bool win (int A, int B) {
	return s[A] > s[B] * dist(A, B);
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d%d%d",&x[i],&y[i],&s[i]);
	}
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) {
			if(i == j || !win(j, i)) continue;
			if(!d[i]) {
				d[i] = j;
				c[i] = 1;
			}
			else {
				int T = cmp(i, d[i], j);
				if(T > 0) {
					d[i] = j;
					c[i] = 1;
				}
				else c[i]++;
			}
		}
		if(c[i] > 1) d[i] = 0;
	}
	for(int i=1;i<=n;i++) {
		if(!d[i]) {
			puts(c[i] ? "D" : "K");
			continue;
		}
		int T = i;
		while(d[T]) T = d[T];
		printf("%d\n", T);
	}
}

Compilation message

countries.cpp: In function 'int main()':
countries.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
countries.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d",&x[i],&y[i],&s[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 1 ms 376 KB Output isn't correct
3 Incorrect 3 ms 376 KB Output isn't correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Incorrect 3 ms 376 KB Output isn't correct
7 Incorrect 3 ms 376 KB Output isn't correct
8 Incorrect 4 ms 376 KB Output isn't correct
9 Incorrect 4 ms 376 KB Output isn't correct
10 Incorrect 4 ms 376 KB Output isn't correct
11 Correct 5 ms 376 KB Output is correct
12 Incorrect 2 ms 376 KB Output isn't correct
13 Correct 3 ms 376 KB Output is correct
14 Incorrect 3 ms 376 KB Output isn't correct
15 Incorrect 3 ms 376 KB Output isn't correct
16 Incorrect 3 ms 376 KB Output isn't correct
17 Incorrect 3 ms 376 KB Output isn't correct
18 Incorrect 4 ms 376 KB Output isn't correct
19 Incorrect 5 ms 376 KB Output isn't correct
20 Incorrect 4 ms 376 KB Output isn't correct