Submission #38099

# Submission time Handle Problem Language Result Execution time Memory
38099 2018-01-01T06:21:22 Z funcsr Ideal city (IOI12_city) C++14
11 / 100
1000 ms 17928 KB
#include <iostream>
#include <vector>
#include <set>
#include <cassert>
#include <queue>
#include <map>
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(xs) xs.begin(), xs.end()
#define pb push_back
#define _1 first
#define _2 second
#define INF 1145141919
#define MOD 1000000000
using namespace std;
int DX[4] = {-1, 0, 1, 0};
int DY[4] = {0, -1, 0, 1};

typedef pair<int, int> P;
map<P, int> mp;
int D[2000][2000];
int DistanceSum(int N, int *X, int *Y) {
  if (N > 2000) abort();
  rep(i, N) {
    mp[P(X[i], Y[i])] = i;
  }
  rep(i, N) rep(j, N) D[i][j] = INF;
  rep(s, N) {
    queue<int> q;
    q.push(s);
    D[s][s] = 0;
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      rep(k, 4) {
        P tp = P(X[x]+DX[k], Y[x]+DY[k]);
        if (mp.find(tp) != mp.end()) {
          int t = mp[tp];
          if (D[s][t] == INF) {
            D[s][t] = D[s][x]+1;
            q.push(t);
          }
        }
      }
    }
  }
  int s = 0;
  rep(i, N) rep(j, i) s = (s + D[i][j]) % MOD;
  return s;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17784 KB Output is correct
2 Correct 0 ms 17784 KB Output is correct
3 Correct 0 ms 17784 KB Output is correct
4 Correct 0 ms 17784 KB Output is correct
5 Correct 3 ms 17784 KB Output is correct
6 Correct 13 ms 17784 KB Output is correct
7 Correct 13 ms 17784 KB Output is correct
8 Correct 13 ms 17784 KB Output is correct
9 Correct 16 ms 17784 KB Output is correct
10 Correct 13 ms 17784 KB Output is correct
11 Correct 16 ms 17784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 559 ms 17916 KB Output is correct
2 Correct 543 ms 17916 KB Output is correct
3 Execution timed out 1000 ms 17916 KB Execution timed out
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 17928 KB Execution killed because of forbidden syscall gettid (186)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 17928 KB Execution killed because of forbidden syscall gettid (186)
2 Halted 0 ms 0 KB -