# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
939289 | fdnfksd | City Mapping (NOI18_citymapping) | C++14 | 41 ms | 10840 KiB |
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>
#include "citymapping.h"
#define pb push_back
#define pli pair<ll,ll>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxn=2e5;
const ll inf=1e18;
const ll mod=1e9+7;
pli cc[maxn];
ll dis[1005][1005];
ll d[maxn];
void find_roads(int N, int Q, int A[], int B[], int W[])
{
ll n=N,q=Q;
if(q==(ll)5e5)
{
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
dis[i][j]=get_distance(i,j);
dis[j][i]=dis[i][j];
}
}
for(int i=2;i<=n;i++)
{
ll luu=0;
for(int j=1;j<=n;j++)
{
if(i==j) continue;
if(dis[i][1]==dis[j][1]+dis[i][j])
{
if(luu=0) luu=j;
else
{
if(dis[i][luu]>dis[i][j]) luu=j;
}
}
}
A[i-2]=i;
B[i-2]=luu;
W[i-2]=dis[i][luu];
}
}
else
{
ll luu=1;
for(int i=1;i<=n;i++)
{
d[i]=get_distance(i,1);
if(d[i]>d[luu]) luu=i;
}
vector<pli>cc;
for(int i=1;i<=n;i++)
{
cc.pb({get_distance(i,1),(ll)i});
}
sort(cc.begin(),cc.end());
for(int i=1;i<cc.size();i++)
{
A[i-1]=cc[i].se;
B[i-1]=cc[i-1].se;
W[i-1]=cc[i].fi-cc[i-1].fi;
}
}
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |