# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
924760 | 2024-02-09T16:03:08 Z | pcc | City Mapping (NOI18_citymapping) | C++14 | 17 ms | 8584 KB |
#include "citymapping.h" #include <bits/stdc++.h> using namespace std; #define pll pair<ll,ll> #define fs first #define sc second #define ll long long #define pii pair<int,int> const int mxn = 1010; vector<pair<ll,pii>> edges; ll dist[mxn][mxn]; queue<vector<int>> q; ll f(int a,int b){ return dist[a][b]?dist[a][b]:dist[a][b] = dist[b][a] = get_distance(a,b); } inline void calc(vector<int> v){ //for(auto &i:v)cout<<i<<',';cout<<endl; if(v.size()<2)return; if(v.size()==2){ edges.push_back(make_pair(f(v[0],v[1]),make_pair(v[0],v[1]))); return; } random_shuffle(v.begin(),v.end()); int a = v[0];pll sm = make_pair(f(a,v[1]),1ll*v[1]); for(int i = 1;i<v.size();i++)sm = min(sm,make_pair(f(a,v[i]),1ll*v[i])); int b = sm.sc; edges.push_back(make_pair(sm.fs,make_pair(a,b))); vector<int> lv,rv; for(auto &i:v){ if(i == a||i == b)continue; if(f(a,i)<f(b,i))lv.push_back(i); else rv.push_back(i); } lv.push_back(a); rv.push_back(b); q.push(lv); q.push(rv); return; } void find_roads(int N, int Q, int A[], int B[], int W[]) { srand(7125); q.push({}); for(int i = 1;i<=N;i++)q.front().push_back(i); while(!q.empty()){ auto v = q.front(); q.pop(); calc(v); } assert(edges.size() == N-1); for(int i = 0;i<edges.size();i++){ W[i] = edges[i].fs; A[i] = edges[i].sc.fs; B[i] = edges[i].sc.sc; } return; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8540 KB | Correct: 18309 out of 500000 queries used. |
2 | Correct | 5 ms | 8584 KB | Correct: 37341 out of 500000 queries used. |
3 | Correct | 14 ms | 8284 KB | Correct: 168041 out of 500000 queries used. |
4 | Correct | 17 ms | 8480 KB | Correct: 234153 out of 500000 queries used. |
5 | Correct | 7 ms | 8540 KB | Correct: 53641 out of 500000 queries used. |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8540 KB | Correct: 18309 out of 500000 queries used. |
2 | Correct | 5 ms | 8584 KB | Correct: 37341 out of 500000 queries used. |
3 | Correct | 14 ms | 8284 KB | Correct: 168041 out of 500000 queries used. |
4 | Correct | 17 ms | 8480 KB | Correct: 234153 out of 500000 queries used. |
5 | Correct | 7 ms | 8540 KB | Correct: 53641 out of 500000 queries used. |
6 | Correct | 4 ms | 8536 KB | Correct: 19805 out of 500000 queries used. |
7 | Correct | 6 ms | 8540 KB | Correct: 38080 out of 500000 queries used. |
8 | Correct | 9 ms | 8540 KB | Correct: 100020 out of 500000 queries used. |
9 | Correct | 10 ms | 8540 KB | Correct: 118484 out of 500000 queries used. |
10 | Correct | 7 ms | 8536 KB | Correct: 51969 out of 500000 queries used. |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 8284 KB | Too many calls to get_distance(). |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 8284 KB | Too many calls to get_distance(). |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 8540 KB | Correct: 18309 out of 500000 queries used. |
2 | Correct | 5 ms | 8584 KB | Correct: 37341 out of 500000 queries used. |
3 | Correct | 14 ms | 8284 KB | Correct: 168041 out of 500000 queries used. |
4 | Correct | 17 ms | 8480 KB | Correct: 234153 out of 500000 queries used. |
5 | Correct | 7 ms | 8540 KB | Correct: 53641 out of 500000 queries used. |
6 | Correct | 4 ms | 8536 KB | Correct: 19805 out of 500000 queries used. |
7 | Correct | 6 ms | 8540 KB | Correct: 38080 out of 500000 queries used. |
8 | Correct | 9 ms | 8540 KB | Correct: 100020 out of 500000 queries used. |
9 | Correct | 10 ms | 8540 KB | Correct: 118484 out of 500000 queries used. |
10 | Correct | 7 ms | 8536 KB | Correct: 51969 out of 500000 queries used. |
11 | Incorrect | 3 ms | 8284 KB | Too many calls to get_distance(). |
12 | Halted | 0 ms | 0 KB | - |