Submission #2126209


Source Code Expand

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,m,a,b,i,cnt=0;
	ll c,d[1234],ans;
	vector<E> g;
	E e;
	bool update,flag = true,done[1234];
	fill(d,d+1234,INFLL);
	fill(done,done+1234,false);
	cin >> n >> m;
	d[1] = 0ll;
	done[1] = true;
	for(i=0; i<m; ++i){
		cin >> a >> b >> c;
		g.push_back(E(-c,P(a,b)));
	}
	while(true){
		update = false;
		for(i=0; i<m; ++i){
			e = g[i];
			if(done[e.from] && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				done[e.to] = true;
				update = true;
			}
		}
		if(!update || cnt>n){
			break;
		}
		cnt++;
	}
	ans = -d[n];
	fill(d,d+1234,0ll);
	fill(done,done+1234,false);
	cnt = 0;
	while(true){
		update = false;
		for(i=0; i<m; ++i){
			e = g[i];
			if(d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				done[e.to] = true;
				update = true;
			}
		}
		if(!update || cnt>n){
			break;
		}
		cnt++;
	}
	if(done[n]){
		cout << "inf" << endl;
	}else{
		cout << ans << endl;
	}
	}
	return 0;
}

Submission Info

Submission Time
Task D - Score Attack
User ransewhale
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1347 Byte
Status CE

Compile Error

./Main.cpp:74:2: error: expected unqualified-id before ‘return’
  return 0;
  ^
./Main.cpp:75:1: error: expected declaration before ‘}’ token
 }
 ^