Submission #28377

# Submission time Handle Problem Language Result Execution time Memory
28377 2017-07-16T05:06:07 Z Sorry AcornCkiGuiziTeam(#1226, gs13068) Alternative Mart (FXCUP2_mart) C++14
1 / 1
1126 ms 46032 KB
#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

mart.cpp: In function 'int main()':
mart.cpp:17:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d", &n, &m, &l, &k);
                                   ^
mart.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &i);
                  ^
mart.cpp:23:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &i, &j, &l);
                              ^
mart.cpp:39:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &i, &j);
                        ^
mart.cpp:40:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   for (l = 0; l < j; l++) scanf("%d", &t[l]);
                                             ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6840 KB Output is correct
2 Correct 0 ms 6840 KB Output is correct
3 Correct 0 ms 6840 KB Output is correct
4 Correct 0 ms 6840 KB Output is correct
5 Correct 3 ms 6840 KB Output is correct
6 Correct 0 ms 6840 KB Output is correct
7 Correct 3 ms 6984 KB Output is correct
8 Correct 3 ms 6840 KB Output is correct
9 Correct 83 ms 11828 KB Output is correct
10 Correct 56 ms 11820 KB Output is correct
11 Correct 36 ms 7488 KB Output is correct
12 Correct 39 ms 6972 KB Output is correct
13 Correct 819 ms 46024 KB Output is correct
14 Correct 713 ms 46032 KB Output is correct
15 Correct 96 ms 9172 KB Output is correct
16 Correct 83 ms 8424 KB Output is correct
17 Correct 526 ms 11096 KB Output is correct
18 Correct 303 ms 8424 KB Output is correct
19 Correct 516 ms 11100 KB Output is correct
20 Correct 356 ms 8424 KB Output is correct
21 Correct 526 ms 13448 KB Output is correct
22 Correct 446 ms 8820 KB Output is correct
23 Correct 546 ms 17988 KB Output is correct
24 Correct 589 ms 12984 KB Output is correct
25 Correct 593 ms 17988 KB Output is correct
26 Correct 579 ms 12984 KB Output is correct
27 Correct 126 ms 10284 KB Output is correct
28 Correct 113 ms 9512 KB Output is correct
29 Correct 679 ms 13728 KB Output is correct
30 Correct 596 ms 11060 KB Output is correct
31 Correct 673 ms 18176 KB Output is correct
32 Correct 593 ms 10948 KB Output is correct
33 Correct 646 ms 13528 KB Output is correct
34 Correct 906 ms 18520 KB Output is correct
35 Correct 766 ms 18120 KB Output is correct
36 Correct 803 ms 18252 KB Output is correct
37 Correct 859 ms 27600 KB Output is correct
38 Correct 956 ms 27468 KB Output is correct
39 Correct 149 ms 10680 KB Output is correct
40 Correct 146 ms 10680 KB Output is correct
41 Correct 969 ms 18740 KB Output is correct
42 Correct 956 ms 18748 KB Output is correct
43 Correct 1036 ms 27964 KB Output is correct
44 Correct 1049 ms 27968 KB Output is correct
45 Correct 1002 ms 28008 KB Output is correct
46 Correct 953 ms 28020 KB Output is correct
47 Correct 926 ms 27864 KB Output is correct
48 Correct 963 ms 27864 KB Output is correct
49 Correct 969 ms 27864 KB Output is correct
50 Correct 1126 ms 27864 KB Output is correct
51 Correct 889 ms 27864 KB Output is correct
52 Correct 869 ms 27864 KB Output is correct
53 Correct 286 ms 8424 KB Output is correct
54 Correct 846 ms 18436 KB Output is correct
55 Correct 636 ms 18416 KB Output is correct
56 Correct 959 ms 28004 KB Output is correct
57 Correct 689 ms 45652 KB Output is correct