Submission #39081

# Submission time Handle Problem Language Result Execution time Memory
39081 2018-01-09T08:09:29 Z 14kg Ideal city (IOI12_city) C++11
23 / 100
29 ms 2680 KB
#define MOD 1000000000
#define INF 2147483646
#define min2(x,y) (x<y?x:y)

int n;
int cnt_X[100001], cnt_Y[100001];

int DistanceSum(int _n, int *X, int *Y) {
	n = _n;

	int x_min=INF, y_min=INF;
	long long out = 0, t1 = 0, t2 = 0, t3;
	for (int i = 0; i < n; i++) x_min = min2(x_min, X[i]), y_min = min2(y_min, Y[i]);
	for (int i = 0; i < n; i++) cnt_X[X[i] - x_min]++, cnt_Y[Y[i] - y_min]++;
	for (int i = 0; i < n; i++) {
		out += t2*(long long)cnt_X[i], out %= MOD;
		t1 += cnt_X[i];
		t2 += t1;
	}
	t1 = t2 = 0;
	for (int i = 0; i < n; i++) {
		out += t2*(long long)cnt_Y[i], out %= MOD;
		t1 += cnt_Y[i];
		t2 += t1;
	}


	return (int)out;
}

Compilation message

city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:12:37: warning: unused variable 't3' [-Wunused-variable]
  long long out = 0, t1 = 0, t2 = 0, t3;
                                     ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2104 KB Output is correct
2 Correct 3 ms 2104 KB Output is correct
3 Correct 13 ms 2288 KB Output is correct
4 Correct 9 ms 2288 KB Output is correct
5 Correct 29 ms 2680 KB Output is correct
6 Correct 19 ms 2680 KB Output is correct
7 Correct 29 ms 2680 KB Output is correct
8 Correct 29 ms 2680 KB Output is correct
9 Correct 23 ms 2680 KB Output is correct
10 Correct 23 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2104 KB Output isn't correct
2 Halted 0 ms 0 KB -