This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
#define ff first
#define ss second
#define pb push_back
/// #define int ll
const int MOD = 1e9;
vector<int> adj[100001];
int DistanceSum(int N, int X[], int Y[]) {
for(int l = 0; l < N; l++) {
for(int i = l + 1; i < N; i++) {
if(X[l] == X[i] && abs(Y[l] - Y[i]) == 1)
adj[l].pb(i), adj[i].pb(l);
if(Y[l] == Y[i] && abs(X[l] - X[i]) == 1)
adj[l].pb(i), adj[i].pb(l);
}
}
ll res = 0;
for(int l = 0; l < N; l++) {
vector<int> dist(N, -1);
queue<int> q; q.push(l); dist[l] = 0;
while(!q.empty()) {
int v = q.front(); q.pop();
if(v > l) res = (res % MOD + dist[v] % MOD) % MOD;
for(auto u : adj[v]) {
if(dist[u] != -1) continue;
dist[u] = dist[v] + 1;
q.push(u);
}
}
}
return res % MOD;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |