Submission #363072

# Submission time Handle Problem Language Result Execution time Memory
363072 2021-02-05T04:13:57 Z casperwang Ideal city (IOI12_city) C++14
0 / 100
65 ms 5996 KB
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
#define debug(args...) kout("[ + " string(#args) + " ]", args)
void kout() { cerr << endl; }
template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); }
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }

const int MOD = 1000000000;
const int INF = 1e18;
const int MAXN = 100000;
vector <int> path[MAXN];
vector <int> deg;
vector <bool> vis;
map <pii,int> appr;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int BFS(int s, int N) {
  vector <int> dis(N, INF);
  dis[s] = 0;
  queue <int> nxt;
  nxt.push(s);
  while (nxt.size()) {
    int now = nxt.front();
    nxt.pop();
    for (int i : path[now]) {
      if (dis[i] == INF) {
        dis[i] = dis[now] + 1;
        nxt.push(i);
      }
    }
  }
  int sum = 0;
  for (int i = s+1; i < N; i++)
    sum += dis[i];
  return sum;
}

void init(int N) {
  for (int i = 0; i < N; i++)
    path[i].clear();
  appr.clear();
  deg.resize(N);
  vis.resize(N);
}

signed DistanceSum(signed N, signed *X, signed *Y) {
  init(N);
  for (int i = 0; i < N; i++)
    appr[pii(X[i], Y[i])] = i;
  int mnX = INF, mxX = 0, mnY = INF, mxY = 0;
  for (int i = 0; i < N; i++) {
    mnX = min(mnX, (int)X[i]);
    mnY = min(mnY, (int)Y[i]);
    mxX = max(mxX, (int)X[i]);
    mxY = max(mxY, (int)Y[i]);
    for (int j = 0; j < 4; j++) {
      if (appr.count(pii(X[i]+dx[j], Y[i]+dy[j]))) {
        int id = appr[pii(X[i]+dx[j], Y[i]+dy[j])];
        path[id].pb(i);
        path[i].pb(id);
      }
    }
  }
  return 0;
  int ans = 0;
  if ((mxX - mnX + 1) * (mxY - mnY + 1) != N) {
    for (int i = 0; i < N; i++)
      ans = (ans + BFS(i, N)) % MOD;
  }
  return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 5996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 5612 KB Output isn't correct
2 Halted 0 ms 0 KB -