Submission #879727

# Submission time Handle Problem Language Result Execution time Memory
879727 2023-11-28T02:30:26 Z NeroZein Ideal city (IOI12_city) C++17
0 / 100
5 ms 604 KB
#include "bits/stdc++.h"
using namespace std; 

const int md = (int) 1e9; 

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1}; 

int DistanceSum(int N, int *X, int *Y) {
  int ret = 0;
  int n = 0, m = 0;
  for (int i = 0; i < N; ++i) {
    n = max(n, X[i]);
    m = max(m, Y[i]); 
  }
  auto sum = [&](int r) {
    return (int) (((long long) r * (r + 1) / 2) % md);
  };
  auto mul = [&](int x, int y) {
    return (int) ((long long) x * y % md); 
  };
  auto add = [&](int& x, int y) {
    x += y;
    if (x >= md) x -= md; 
  };
  for (int i = 0; i < N; ++i) {
    int x = X[i], y = Y[i];
    int sx = mul(sum(x - 1), m);
    add(sx, mul(sum(n - x), m)); 
    int sy = mul(sum(y - 1), n);
    add(sy, mul(sum(m - y), n)); 
    add(ret, sx);
    add(ret, sy); 
  }
  return ret;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -