Submission #1856652
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define inf 100000000000 ll prim(ll n, vector< pair<ll, ll> > locations){ ll d[n]; ll ans = 0; fill(d, d + n, inf); set<pair<ll,ll> > s; for(ll i = 0;i < n;i ++){ s.insert({d[i],i}); } ll v; while(!s.empty()){ v = s.begin() -> second; if(d[v] != inf){ ans+=d[v]; } d[v] = 0; s.erase(s.begin()); for(ll i = 0; i < n; i++){ ll t1 = locations[i].first; ll t2 = locations[v].first; ll t3 = locations[i].second; ll t4 = locations[v].second; if(t1 > t2){t1 -= t2;} else{t1 = (t2-t1);} if(t3 > t4){t3 -= t4;} else{t3 = (t4-t3);} ll w = min(t1, t3); if(d[i] > w){ s.erase({d[i], i}); d[i] = w; s.insert({d[i], i}); } } } return ans; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n, x, y; cin >> n; vector< pair<ll, ll> > loc; for(ll one = 0; one < n; one++){ cin >> x >> y; pair<ll, ll> temp = make_pair(x, y); loc.push_back(temp); } cout << prim(n, loc); }
Submission Info
Submission Time | |
---|---|
Task | D - Built? |
User | vjudge1 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1190 Byte |
Status | TLE |
Exec Time | 2104 ms |
Memory | 12528 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | TLE | 2104 ms | 12528 KB |
02.txt | TLE | 2104 ms | 10352 KB |
03.txt | TLE | 2104 ms | 10352 KB |
04.txt | TLE | 2104 ms | 10480 KB |
05.txt | TLE | 2104 ms | 12528 KB |
06.txt | TLE | 2104 ms | 10480 KB |
07.txt | TLE | 2104 ms | 10480 KB |
08.txt | TLE | 2104 ms | 10480 KB |
09.txt | TLE | 2104 ms | 10352 KB |
10.txt | TLE | 2104 ms | 10480 KB |
11.txt | TLE | 2104 ms | 10352 KB |
12.txt | TLE | 2104 ms | 10480 KB |
13.txt | TLE | 2104 ms | 10480 KB |
14.txt | TLE | 2104 ms | 12528 KB |
15.txt | TLE | 2104 ms | 10480 KB |
16.txt | TLE | 2104 ms | 10352 KB |
17.txt | TLE | 2104 ms | 10480 KB |
18.txt | TLE | 2104 ms | 12528 KB |
19.txt | TLE | 2104 ms | 10480 KB |
20.txt | TLE | 2104 ms | 10480 KB |
21.txt | TLE | 2104 ms | 10480 KB |
22.txt | TLE | 2104 ms | 10480 KB |
23.txt | TLE | 2104 ms | 12528 KB |
24.txt | TLE | 2104 ms | 10352 KB |
25.txt | AC | 1 ms | 256 KB |
26.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |