Submission #28373

# Submission time Handle Problem Language Result Execution time Memory
28373 2017-07-16T05:04:11 Z Sorry AcornCkiGuiziTeam(#1226, gs13068) Alternative Mart (FXCUP2_mart) C++14
0 / 1
0 ms 6840 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 Incorrect 0 ms 6840 KB Output isn't correct
4 Halted 0 ms 0 KB -