/*#pragma GCC optimize("O3")*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#define ordered_set tree<int, null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 1000000000
#define PI 3.14159265358979323846
using namespace std;
int inc[4][2]={{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
int DistanceSum(int N, int *X, int *Y)
{
long long ans=0;
for(int i = 0; i < N; i++)
{
set<pair<int, int> >s;
for(int j = 0; j < N; j++)
{
if(j!=i)
{
s.insert(make_pair(X[j], Y[j]));
}
}
int nb=0, idx=0;
vector<pair<int, int> >bfs;
bfs.push_back(make_pair(X[i], Y[i]));
while(!s.empty())
{
int l=bfs.size();
for(int j = idx; j < l; j++)
{
ans+=nb;
ans%=MOD2;
for(int k = 0; k < 4; k++)
{
int xx=bfs[j].first+inc[k][0], yy=bfs[j].second+inc[k][1];
if(s.count(make_pair(xx, yy)))
{
s.erase(make_pair(xx, yy));
bfs.push_back(make_pair(xx, yy));
}
}
}
nb++;
idx=l;
}
}
ans*=(500000004);
ans%=MOD2;
return ans;
}
//size
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
552 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1093 ms |
2084 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1088 ms |
2316 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |