# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28373 | Sorry AcornCkiGuiziTeam (#68) | Alternative Mart (FXCUP2_mart) | C++14 | 0 ms | 6840 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
priority_queue<pair<int, pair<int, int> > > pq;
vector<pair<int, int> > g[50005];
pair<int, int> d[50005][11];
int dn[50005];
int t[11];
int main() {
int i, j, k, l, m, n;
scanf("%d%d%d%d", &n, &m, &l, &k);
while (l--) {
scanf("%d", &i);
pq.emplace(0, make_pair(i, -i));
}
while (m--) {
scanf("%d%d%d", &i, &j, &l);
g[i].emplace_back(j, l);
g[j].emplace_back(i, l);
}
while (!pq.empty()) {
auto p = pq.top();
pq.pop();
if (dn[p.second.first] == 11) continue;
for (i = 0; i < dn[p.second.first]; i++) if (d[p.second.first][i].second == p.second.second) break;
if (i < dn[p.second.first]) continue;
d[p.second.first][dn[p.second.first]].first = -p.first;
d[p.second.first][dn[p.second.first]].second = -p.second.second;
dn[p.second.first]++;
for (auto &t : g[p.second.first]) pq.emplace(p.first - t.second, make_pair(t.first, p.second.second));
}
while (k--) {
scanf("%d%d", &i, &j);
for (l = 0; l < j; l++) scanf("%d", &t[l]);
for (l = 0;; l++) {
for (m = 0; m < j; m++) if (t[m] == d[i][l].second) break;
if (m == j) break;
}
printf("%d %d\n", d[i][l].second, d[i][l].first);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |