# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28709 | 2017-07-16T08:56:06 Z | tlwpdus 팬클럽 회장(#1123, kdh9949) | Alternative Mart (FXCUP2_mart) | C++14 | 5000 ms | 40020 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; struct Dat{ int s, x, d; bool operator<(const Dat &oth) const { return (d == oth.d) ? (s > oth.s) : (d > oth.d); } }; const int inf = 1e9; int n, m, k, q, chk[50010]; set<pii> md[50010]; vector<pii> e[50010]; priority_queue<Dat> pq; int main(){ scanf("%d%d%d%d", &n, &m, &k, &q); for(int i = 1, x; i <= k; i++){ scanf("%d", &x); md[x].insert(pii(0, x)); pq.push({x, x, 0}); } for(int x, y, c; m--; ){ scanf("%d%d%d", &x, &y, &c); e[x].push_back({y, c}); e[y].push_back({x, c}); } while(!pq.empty()){ Dat c = pq.top(); pq.pop(); int fl = 1; for(auto &i : md[c.x]){ if(i.second == c.s && i.first < c.d){ fl = 0; break; } } if(!fl) continue; for(auto &i : e[c.x]){ int nx, nd; tie(nx, nd) = i; nd += c.d; int fl = 1; for(auto &i : md[nx]){ if(i.second == c.s && i.first <= nd){ fl = 0; break; } } if(!fl) continue; for(auto &i : md[nx]){ if(i.second == c.s){ md[nx].erase(i); break; } } md[nx].insert(pii(nd, c.s)); while(md[nx].size() > 11){ auto t = md[nx].end(); t--; md[nx].erase(t); } auto t = md[nx].end(); t--; if(md[nx].find(pii(nd, c.s)) != md[nx].end()) pq.push({c.s, nx, nd}); } } for(int i = 1, x, c; i <= q; i++){ scanf("%d%d", &x, &c); for(int y; c--; ){ scanf("%d", &y); chk[y] = i; } for(auto &j : md[x]){ if(chk[j.second] == i) continue; printf("%d %d\n", j.second, j.first); break; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 5740 KB | Output is correct |
2 | Correct | 0 ms | 5740 KB | Output is correct |
3 | Correct | 0 ms | 5740 KB | Output is correct |
4 | Correct | 0 ms | 5740 KB | Output is correct |
5 | Correct | 0 ms | 5740 KB | Output is correct |
6 | Correct | 3 ms | 5740 KB | Output is correct |
7 | Correct | 3 ms | 6004 KB | Output is correct |
8 | Correct | 3 ms | 6004 KB | Output is correct |
9 | Correct | 329 ms | 6612 KB | Output is correct |
10 | Correct | 26 ms | 6548 KB | Output is correct |
11 | Correct | 66 ms | 8552 KB | Output is correct |
12 | Correct | 59 ms | 8512 KB | Output is correct |
13 | Correct | 3736 ms | 14868 KB | Output is correct |
14 | Correct | 3746 ms | 14876 KB | Output is correct |
15 | Correct | 153 ms | 10036 KB | Output is correct |
16 | Correct | 126 ms | 9700 KB | Output is correct |
17 | Correct | 1469 ms | 31860 KB | Output is correct |
18 | Correct | 799 ms | 30820 KB | Output is correct |
19 | Correct | 1906 ms | 35000 KB | Output is correct |
20 | Correct | 1126 ms | 33064 KB | Output is correct |
21 | Correct | 1949 ms | 35000 KB | Output is correct |
22 | Correct | 1643 ms | 33140 KB | Output is correct |
23 | Correct | 2436 ms | 36420 KB | Output is correct |
24 | Correct | 2596 ms | 34620 KB | Output is correct |
25 | Correct | 2683 ms | 36420 KB | Output is correct |
26 | Correct | 2423 ms | 34620 KB | Output is correct |
27 | Correct | 133 ms | 10532 KB | Output is correct |
28 | Correct | 153 ms | 10244 KB | Output is correct |
29 | Correct | 2296 ms | 32976 KB | Output is correct |
30 | Correct | 1879 ms | 31788 KB | Output is correct |
31 | Correct | 2889 ms | 36604 KB | Output is correct |
32 | Correct | 2279 ms | 34020 KB | Output is correct |
33 | Correct | 2633 ms | 35048 KB | Output is correct |
34 | Correct | 4033 ms | 36932 KB | Output is correct |
35 | Correct | 3279 ms | 36684 KB | Output is correct |
36 | Correct | 3553 ms | 36816 KB | Output is correct |
37 | Correct | 4519 ms | 40020 KB | Output is correct |
38 | Correct | 3743 ms | 36816 KB | Output is correct |
39 | Correct | 153 ms | 11056 KB | Output is correct |
40 | Correct | 156 ms | 11084 KB | Output is correct |
41 | Correct | 2829 ms | 34860 KB | Output is correct |
42 | Correct | 2819 ms | 34892 KB | Output is correct |
43 | Correct | 4583 ms | 37236 KB | Output is correct |
44 | Correct | 4543 ms | 37132 KB | Output is correct |
45 | Execution timed out | 5000 ms | 37196 KB | Execution timed out |
46 | Halted | 0 ms | 0 KB | - |