Submission #63933

# Submission time Handle Problem Language Result Execution time Memory
63933 2018-08-03T07:15:48 Z Scayre Evacuation plan (IZhO18_plan) C++14
0 / 100
616 ms 150112 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <vector>
#include <set>
#include <cassert>
#define mp make_pair
#define pb push_back
#define ll long long
using namespace std;

const int MAXN = 1e6;
const int INF = 1e9 + 7;
vector <pair <int, int> > a[MAXN];
int dp[MAXN];
ll ans = 0;
set <pair <int, int> > SS;
int main() {
  	freopen("plan.in","r",stdin);
  	freopen("plan.out","w",stdout);
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		int x, y, w;
		scanf("%d%d%d", &x, &y, &w);
		a[x].pb(mp(y, w));
		a[y].pb(mp(x, w));
		SS.insert(mp(x, y));
		SS.insert(mp(y, x));
	}
	int A;
	scanf("%d", &A);
	for (int i = 1; i <= n; i++) {
		dp[i] = INF;
	}
	for (int i = 1; i <= A; i++) {
		int x;
		scanf("%d", &x);
		a[0].pb(mp(x, 0));
	}
	set <pair <int, int> > S;
	S.insert(mp(0, 0));
	while (!S.empty()) {
		int x = S.begin()->second;
		S.erase(S.begin());
		for (int i = 0; i < a[x].size(); i++) {
			int to = a[x][i].first;
			int w = a[x][i].second;
			if (dp[to] > dp[x] + w) {
				S.erase(mp(dp[to], to));
				dp[to] = dp[x] + w;
				S.insert(mp(dp[to], to));
			}
		}
	}
	int Q;
	scanf("%d", &Q);
	ll ans = 0;
	for (int i = 1; i <= Q; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		ans += min(dp[x], dp[y]);
		printf("%d\n", min(dp[x], dp[y]));
	}
	//cout << ans;


	return 0;
}

Compilation message

plan.cpp: In function 'int main()':
plan.cpp:46:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < a[x].size(); i++) {
                   ~~^~~~~~~~~~~~~
plan.cpp:19:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    freopen("plan.in","r",stdin);
    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
plan.cpp:20:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    freopen("plan.out","w",stdout);
    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
plan.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
plan.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &x, &y, &w);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
plan.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &A);
  ~~~~~^~~~~~~~~~
plan.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
plan.cpp:57:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &Q);
  ~~~~~^~~~~~~~~~
plan.cpp:61:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &x, &y);
   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 597 ms 150112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 597 ms 150112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 616 ms 150060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 598 ms 150076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 597 ms 150112 KB Output isn't correct
2 Halted 0 ms 0 KB -