#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int n;
vector<int> muchii[250005];
struct point
{
int x,y;
} v[250005];
ll dist[250005];
priority_queue<pii,vector<pii>,greater<pii>> coada;
void bfs(int start)
{
for(int i=1;i<=n;i++)
dist[i]=1e9;
dist[start]=0;
coada.push({0,start});
while(!coada.empty())
{
int nod=coada.top().second;
coada.pop();
for(int i:muchii[nod])
if(dist[i]>dist[nod]+1)
{
dist[i]=dist[nod]+1;
coada.push({dist[i],i});
}
}
}
int sol[250005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
cin>>v[i].x>>v[i].y;
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
if(v[i].x<v[j].x&&v[i].y<v[j].y)
{
muchii[i].push_back(j);
muchii[j].push_back(i);
}
else if(v[i].x>v[j].x&&v[i].y>v[j].y)
{
muchii[i].push_back(j);
muchii[j].push_back(i);
}
}
}
for(int i=1;i<=n;i++)
{
bfs(i);
ll suma=0;
for(int j=1;j<=n;j++)
suma+=dist[j];
cout<<suma<<'\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6228 KB |
Output is correct |
2 |
Correct |
4 ms |
6228 KB |
Output is correct |
3 |
Correct |
4 ms |
6228 KB |
Output is correct |
4 |
Correct |
4 ms |
6228 KB |
Output is correct |
5 |
Correct |
3 ms |
6100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
285 ms |
6920 KB |
Output is correct |
2 |
Correct |
1301 ms |
13456 KB |
Output is correct |
3 |
Correct |
170 ms |
6356 KB |
Output is correct |
4 |
Correct |
1247 ms |
13316 KB |
Output is correct |
5 |
Correct |
1161 ms |
12568 KB |
Output is correct |
6 |
Correct |
140 ms |
6484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2091 ms |
11152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2017 ms |
262144 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1122 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |