답안 #1005925

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005925 2024-06-23T08:05:07 Z 정민찬(#10832) 이상적인 도시 (IOI12_city) C++14
23 / 100
13 ms 5316 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const ll mod = 1e9;

int DistanceSum(int _N, int *_X, int *_Y) {
    ll N = _N;
    vector<ll> X(N), Y(N);
    for (ll i=0; i<N; i++) {
        X[i] = _X[i];
        Y[i] = _Y[i];
    }
    ll mnX = *min_element(X.begin(), X.end());
    ll mnY = *min_element(Y.begin(), Y.end());
    for (ll i=0; i<N; i++) {
        X[i] -= mnX - 1;
        Y[i] -= mnY - 1;
    }
    vector<ll> SX(N+1, 0), SY(N+1, 0);
    for (ll i=0; i<N; i++) {
        SX[X[i]] ++;
        SY[Y[i]] ++;
    }
    for (ll i=1; i<=N; i++) {
        SX[i] += SX[i-1];
        SY[i] += SY[i-1];
    }
    ll ans = 0;
    for (ll i=0; i<N; i++) {
        ans += X[i] * SX[X[i]-1];
        ans -= X[i] * (N - SX[X[i]]);
        ans += Y[i] * SY[Y[i]-1];
        ans -= Y[i] * (N - SY[Y[i]]);
        ans %= mod;
        ans = (ans + mod) % mod;
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1116 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 6 ms 2652 KB Output is correct
4 Correct 6 ms 2652 KB Output is correct
5 Correct 11 ms 5144 KB Output is correct
6 Correct 11 ms 4972 KB Output is correct
7 Correct 13 ms 5316 KB Output is correct
8 Correct 13 ms 4964 KB Output is correct
9 Correct 11 ms 4952 KB Output is correct
10 Correct 12 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -