[ create a new paste ] login | about

Link: http://codepad.org/mz0aSTGK    [ raw code | output | fork ]

didyxdi - C++, pasted on Sep 3:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
#include<cctype>
#include<string>
#include<string.h>
#include<list>
#include<strstream>
using namespace std;

typedef long long ll;
const ll INF=2013031600;

int n,m;
int u[105],v[105];
ll cost[105];
ll dist[105];

void init()
{
	for(int i=0;i<=100;i++) dist[i]=INF;
}

bool bf()
{
	dist[0]=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(dist[v[j]]>dist[u[j]]+cost[j])
			dist[v[j]]=dist[u[j]]+cost[j];
		}
	}
	for(int i=1;i<=m;i++)
	{
		if(dist[v[i]]>dist[u[i]]+cost[i]) return false;
	}
	return true;
}

int main()
{
	scanf("%d",&n);
	while(n!=0)
	{
		init();
		scanf("%d",&m);
		for(int i=1;i<=m;i++)
		{
			int a,b;ll k;char c[5];
			scanf("%d%d%s%I64d",&a,&b,c,&k);
			if(c[0]=='g')
			{
				u[i]=a+b;v[i]=a-1;cost[i]=-k-1;
			}
			else
			{
				u[i]=a-1;v[i]=a+b;cost[i]=k-1;
			}
		}
		if(bf()) printf("lamentable kingdom\n"); else printf("successful conspiracy\n");
		scanf("%d",&n);
	}
	return 0;
}


Output:
1
2
Line 20: error: ISO C++ does not support 'long long'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: