Submission #66800

# Submission time Handle Problem Language Result Execution time Memory
66800 2018-08-12T10:26:53 Z MrTEK Commuter Pass (JOI18_commuter_pass) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define fi first
#define sc second
#define d1(w) cerr<<#w<<":"<<w<<endl;
#define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl;
#define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl;
#define left ind+ind
#define right ind+ind+1
#define mid (l+r)/2
#define FAST_IO ios_base::sync_with_stdio(false);
#define endl '\n'
#define int long long

const int maxn = 620;
const long long LINF = 1e18;
const int LOG = 31;
const int INF = 1e9;
const int N = 1e5 + 5;
const int M = 1e4 + 5;
const int SQ = 350
const int MOD = 998244353;

typedef pair <int,int> pii;

struct comp_node {
	int cur;
	long long cost,mnu,mnv;
};

bool operator < (comp_node x,comp_node y) {
	return x.cost > y.cost;
}
struct node {
	int cur;
	long long cost;
};

bool operator < (node x,node y) {
	return x.cost > y.cost;
}

priority_queue <node> Q;
priority_queue <comp_node> CQ;

vector <pair <int,int> > ed[N];

int n,m,s,t,u,v;
long long sp,cu[N],cv[N],ans = LINF,vis[N];

void sp_s(){
	for (int i = 1 ; i <= n ; i++) vis[i] = LINF;
	CQ.push({s,0,cu[s],cv[s]});
	while(len(CQ)) {
		auto temp = CQ.top();
		CQ.pop();
		int cur = temp.cur;
		long long cost = temp.cost,mnu = temp.mnu,mnv = temp.mnv;
		if (vis[cur] < cost || (vis[cur] == cost && cur != t)) continue;
		vis[cur] = cost;
		if (cur == t) ans = min(ans,mnu + mnv);
		for (auto i : ed[cur]) CQ.push({i.fi,cost + i.sc,min(mnu,cu[i.fi]),min(mnv,cv[i.fi])});
	}
	while(len(CQ)) CQ.pop();
	memset(vis,0,sizeof vis);	
}

void sp_u(){
	Q.push({u,0});
	while(len(Q)) {
		auto temp = Q.top();
		Q.pop();
		int cur = temp.cur;
		long long cost = temp.cost;
		if (vis[cur]) continue;
		vis[cur] = 1;
		cu[cur] = cost;
		for (auto i : ed[cur]) Q.push({i.fi,cost + i.sc});
	}
	memset(vis,0,sizeof vis);
	while(len(Q)) Q.pop();
}

void sp_v(){
	Q.push({v,0});
	while(len(Q)) {
		auto temp = Q.top();
		Q.pop();
		int cur = temp.cur;
		long long cost = temp.cost;
		if (vis[cur]) continue;
		vis[cur] = 1;
		cv[cur] = cost;
		for (auto i : ed[cur]) Q.push({i.fi,cost + i.sc});
	}
	memset(vis,0,sizeof vis);
	while(len(Q)) Q.pop();
}

main() {

	scanf("%lld %lld %lld %lld %lld %lld",&n,&m,&s,&t,&u,&v);
	for (int i = 1 ; i <= m ; i++) {
		int u,v,c;
		scanf("%lld %lld %lld",&u,&v,&c);
		ed[u].pb(mp(v,c));
		ed[v].pb(mp(u,c));
	}
	sp_u();
	sp_v();
	sp_s();
	printf("%lld\n",min(ans,cu[v]));
}

Compilation message

commuter_pass.cpp:26:1: error: expected ',' or ';' before 'const'
 const int MOD = 998244353;
 ^~~~~
commuter_pass.cpp:104:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:106:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld %lld %lld %lld",&n,&m,&s,&t,&u,&v);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:109:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld",&u,&v,&c);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~