제출 #121859

#제출 시각아이디문제언어결과실행 시간메모리
121859TuGSGeReL이상적인 도시 (IOI12_city)C++14
23 / 100
29 ms1408 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound
#define inbuf_len 1 << 16
#define outbuf_len 1 << 16

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;

ll cx[100001], cy[100001], mod = 1e9;

int DistanceSum(int n, int *x, int *y) {
	int mnx = INT_MAX, mny = INT_MAX;
	
	for (int i = 0; i < n; i++)
	{
		mnx = min(mnx, x[i]);
		mny = min(mny, y[i]);
	}
	
	for (int i = 0; i < n; i++)
	{
		x[i] -= mnx;
		y[i] -= mny;
	}
	
	if ( n <= 0 )
	{
		
	} else {
		for (int i = 0; i < n; i++)
		{
			cx[x[i]]++;
			cy[y[i]]++;
		}
		
		ll sx = 0, ans = 0, sy = 0, ssx = 0, ssy = 0;
		
		for (int i = n; i >= 0; i--)
		{
			ans = (ans + ((ssx * cx[i]) % mod + (cy[i] * ssy) % mod) % mod) % mod;
			sy = (sy + cy[i]) % mod;
			sx = (sx + cx[i]) % mod;
			ssx = (ssx + sx) % mod;
			ssy = (ssy + sy) % mod;
		}
		
		return ans;
	}
}
//
//int main() {
//  int tmp;
//
//  int N, i;
//  scanf("%d", &N);
//
//  int sq_x[100001], sq_y[100001];
//  for (i = 0; i < N; i++) {
//    tmp = scanf("%d %d", &sq_x[i], &sq_y[i]);
//  }
//
//  int ds = DistanceSum(N, sq_x, sq_y);
//  printf("%d\n", ds);
//
//  return 0;
//
//}

컴파일 시 표준 에러 (stderr) 메시지

city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...