제출 #316789

#제출 시각아이디문제언어결과실행 시간메모리
316789amunduzbaev이상적인 도시 (IOI12_city)C++14
11 / 100
6 ms1280 KiB
//#include "grader.cpp" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int N=205, mod= 1e9; int used[N][N], x[N], y[N], n, dist[N][N], pos[N][N]; vector<vector<int>> edges(2005); vector<pair<int,int>> pi; void Dijkstra(int cur){ queue<int>q; q.push(cur); dist[cur][cur]=0; while(!q.empty()){ int u=q.front(); q.pop(); for(auto x:edges[u]){ if(dist[cur][u]+1 < dist[cur][x]){ dist[cur][x] = dist[cur][u]+1; q.push(x); } } } } pair<int,int> four [4] = {{-1,0}, {+1,0}, {0,-1}, {0,+1}}; int DistanceSum(int N, int *X, int *Y) { n=N; for(int i=0;i<n;i++){ x[i]=X[i]; y[i]=Y[i]; pi.pb({x[i], y[i]}); used[x[i]][y[i]]=1; pos[x[i]][y[i]]=i; for(int j=0;j<n;j++) dist[i][j]=2e9; } for(int i=0;i<n;i++){ for(int j=0;j<4;j++){ int x1 = x[i]+four[j].first, y1 = y[i]+four[j].second; if(used[x1][y1]) edges[i].pb(pos[x1][y1]); } } for(int i=0;i<n;i++) Dijkstra(i); int ans=0; for(int i=0; i<n; i++){ for(int j=i+1; j<n;j++){ ans += dist[i][j]; ans %= mod; } } return ans; } /* 11 2 5 2 6 3 3 3 6 4 3 4 4 4 5 4 6 5 3 5 4 5 6 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...