Submission details
Task:Ping
Sender:Team Purkka
Submission time:2015-09-09 18:56:50 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:54:37: error: 'function' was not declared in this scope
    priority_queue<pint,vector<pint>,function<bool(pint,pint)>> pcstack(lt);
                                     ^
input/code.cpp:54:60: error: expression list treated as compound expression in functional cast [-fpermissive]
    priority_queue<pint,vector<pint>,function<bool(pint,pint)>> pcstack(lt);
                                                            ^
input/code.cpp:54:61: error: template argument 3 is invalid
    priority_queue<pint,vector<pint>,function<bool(pint,pint)>> pcstack(lt);
                                                             ^
input/code.cpp:54:71: error: invalid type in declaration before '(' token
    priority_queue<pint,vector<pint>,function<bool(pint,pint)>> pcstack(lt);
                                                                       ^
input/code.cpp:54:74: error: invalid conversion from 'bool (*)(pint, pint) {aka bool (*)(std::pair...

Code

#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#define INF 1000000001

using namespace std;

typedef pair<int,int> pint;

/*
pcs = koneita
connc = yhteyksiä max
ping = max haluttu ping
dists = etäisyydet[kone]
conn = yhteydet[kone][i]
start = yhteyden alku
end = yhteyden loppu
this_ping = yhteyden ping
pcstack = dijkstran hakupino
curr = alkio sen päällä
con = läpikäytävä alkio
*/

bool lt(pint a, pint b)
{
	return a.second > b.second;
}

int main() {
	cin.tie(0);
	cin.sync_with_stdio(false);
	int pcs, connc, ping;
	cin>>pcs>>connc>>ping;

	int dists[pcs];
	for (int i = 0; i < pcs; i++)
	{
		dists[i] = INF;
	}
	dists[0] = 0;
	int ans = INF;
	vector<pair<int, int>> conn[pcs];
	for (int i = 0; i < connc; i++) {
		int start, end, this_ping;
		cin>>start>>end>>this_ping;
		start--; end--;
		if (this_ping <= ping && ans == INF) {
			conn[start].push_back(make_pair(end, this_ping));
			conn[end].push_back(make_pair(start, this_ping));
			priority_queue<pint,vector<pint>,function<bool(pint,pint)>> pcstack(lt);
			pcstack.push(make_pair(start, 0));
			while (!pcstack.empty()) {
				pint curr = pcstack.top();
				pcstack.pop();
				for (pint con : conn[curr.first]) {
					if (dists[curr.first] + con.second <= ping &&
							dists[curr.first] + con.second < dists[con.first]) {
						dists[con.first] = dists[curr.first]+ con.second;
						pcstack.push(make_pair(con.first, dists[con.first]));
					}
				}
			}
			if (dists[pcs - 1] <= ping) ans = i;
		}
	}

	if (ans == INF) cout<<"QAQ"<<endl;
	else cout<<ans + 1<<endl;

	return 0;
}