Submission #234811

# Submission time Handle Problem Language Result Execution time Memory
234811 2020-05-25T17:40:05 Z crossing0ver Ideal city (IOI12_city) C++17
0 / 100
1000 ms 6008 KB
#include<bits/stdc++.h>
using namespace std;
int vis[100001],x,y,t,help,d[1000001];
map<pair<int,int>,int> mp;
vector<int> adj[100000];
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int DistanceSum(int N, int *X, int *Y) {
  int sum = 0;
  for (int i = 0; i < N; i++) 
  	mp[{X[i],Y[i]}] = i;
  for (int i = 0; i < N;i ++) {
  	for (int j = 0; j < 4; j++) {
  		x = X[i] + dx[j];
  		y = Y[i] + dy[j];
  		t = mp[{x,y}];
		if (t) adj[i].push_back(t);
	  } 
  }	
  for (int i = 0; i < N; i++) {
  	help++;
  	queue<int> q;
  	q.push(i);
  	d[i] = 0;
  	vis[i] = help;
  	while (!q.empty()) {
  		x = q.front();
  		q.pop();
  		sum += d[x];
  		for (int j:adj[x]) {
  			if (vis[j]  != help ) {
  				vis[j] = help;
  				d[j] = d[x] + 1;
  				q.push(j);
			  }
		  }
		  if (sum >= 1e9) sum -= 1e9;
	  }
  }
  return sum/2;
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 2816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 5112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 6008 KB Time limit exceeded
2 Halted 0 ms 0 KB -