제출 #586486

#제출 시각아이디문제언어결과실행 시간메모리
586486hibikiCity Mapping (NOI18_citymapping)C++11
0 / 100
2 ms1108 KiB
#include "citymapping.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define f first #define s second #define sz(x) (int)x.size() #define all(x) x.begin(),x.end() long long has[1005][1005]; vector<pair<pair<int,int>,int> > ans; long long ask(int a, int b) { if(a > b) swap(a,b); if(has[a][b]) return has[a][b]; return has[a][b] = get_distance(a, b); } void gen(int idx, vector<int> child) { vector<pair<int,int> > dis, near; vector<int> n_child[10]; for(auto c: child) dis.pb({ask(idx, c), c}); sort(all(dis)); near.pb(dis[0]); for(int i = 1; i < sz(dis); i++) { for(int j = 0; j < sz(near); j++) { int ret = ask(near[j].s, dis[i].s); if(ret + near[j].f == dis[i].f) n_child[j].pb(dis[i].s); else if(j == sz(near) - 1) near.pb(dis[i]); } } for(int i = 0; i < sz(near); i++) { auto val = near[i]; ans.pb({{idx, val.s}, val.f}); gen(val.s, n_child[i]); } } void find_roads(int N, int Q, int A[], int B[], int W[]) { for (int i = 0; i < N - 1; i++) { A[i] = 1; B[i] = 2; W[i] = 1; } vector<int> temp; for(int i = 2; i <= N; i++) temp.pb(i); gen(1, temp); return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...