QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#391644#3788. Funny Car Racingucup-team12510 30ms7296kbC++201.7kb2024-04-16 17:55:102024-04-16 17:55:10

Judging History

你现在查看的是最新测评结果

  • [2024-04-16 17:55:10]
  • 评测
  • 测评结果:0
  • 用时:30ms
  • 内存:7296kb
  • [2024-04-16 17:55:10]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define Buff ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int N = 5e4 + 5;
const ll mx = 1e9 + 3;

int n, m, s, t, cnt;
int head[N];
ll dist[N];

struct node
{
	int to, nexx;
	ll a, b, t;
}edge[N * 2];

void add(int u, int v, ll a, ll b, ll t)
{
	edge[cnt].to = v;
	edge[cnt].nexx = head[u];
	edge[cnt].a = a;
	edge[cnt].b = b;
	edge[cnt].t = t;
	head[u] = cnt++;
}

void solve()
{
	int TT = 1;
	while(cin >> n >> m >> s >> t)
	{
		memset(head, -1, sizeof(head));
		cnt = 0;
		vector<int> deg(n + 5, 0);
		for(int i = 1; i <= n; i++) dist[i] = 1e18;
		for(int i = 1; i <= m; i++)
		{
			int u, v;
			ll a, b, tt;
			cin >> u >> v >> a >> b >> tt;
			add(u, v, a, b, tt);
			add(v, u, a, b, tt);
			deg[u]++, deg[v]++;
		}

		queue < pair<int, ll >> q;
		q.push({s, 0});
		dist[s] = 0;
		while(q.size())
		{
			ll u = q.front().first, w = q.front().second;
			q.pop();

			for(int i = head[u]; i != -1; i = edge[i].nexx)
			{
				int to = edge[i].to;
				ll a = edge[i].a, b = edge[i].b, tt = edge[i].t;

				ll ww = w;
				int time = ww % (a + b);
				                                   
				if(time + tt <= a) ww = max(ww, w + tt);
				else ww = max(ww, w + (a + b - time) + tt);
				dist[to] = min(dist[to], max(dist[u], ww));
				deg[to]--;
				if(deg[to] == 1) q.push({to, ww});
			}
		}

		cout << "Case " << TT++ << ": ";
		cout << dist[t] << '\n';
	}
}

int main()
{
	Buff;
	int N = 1;
	//cin >> N;
	while(N--)
		solve();
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 30ms
memory: 7296kb

input:

155 9507 117 14
19 18 2 123 1
100 97 4 155 3
121 120 1 140 1
5 8 1 121 1
69 66 2 107 2
151 150 2 190 1
68 69 1 101 1
61 60 2 126 1
124 127 2 160 3
59 55 5 133 4
66 67 1 189 1
94 96 2 108 2
65 63 2 181 2
44 48 1 130 1
28 29 1 180 1
5 6 1 107 1
29 28 1 120 1
142 140 4 152 2
46 45 2 113 1
85 88 6 163 3...

output:

Case 1: 1000000000000000000
Case 2: 1000000000000000000
Case 3: 1000000000000000000
Case 4: 1000000000000000000
Case 5: 1000000000000000000
Case 6: 1000000000000000000
Case 7: 1000000000000000000
Case 8: 1000000000000000000
Case 9: 1000000000000000000
Case 10: 1000000000000000000
Case 11: 1000000000...

result:

wrong answer 1st lines differ - expected: 'Case 1: 249', found: 'Case 1: 1000000000000000000'