QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#391632#3788. Funny Car Racingucup-team12510 36ms7080kbC++171.6kb2024-04-16 17:45:542024-04-16 17:45:56

Judging History

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

  • [2024-04-16 17:45:56]
  • 评测
  • 测评结果:0
  • 用时:36ms
  • 内存:7080kb
  • [2024-04-16 17:45:54]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
#define pii pair <int, int>

struct node
{
	int t, pos, from;
	bool operator < (const node k) const
	{
		if (t != k.t)
		{
			return t > k.t;
		}
		return pos > k.pos;
	}
};

int tt = 1;
void solve(int n, int m, int S, int T)
{
	vector <vector <pair <pii, pii> > > s(n + 1); // v a b t
	for (int i = 1; i <= m; i++)
	{
		int u, v, a, b, t;
		cin >> u >> v >> a >> b >> t;
		if (t <= a)
			s[u].push_back({{v, a}, {b, t}});
	}
	priority_queue <node> q;
	q.push({0, S, 0});
	vector <vector <int>> dist(n + 1, vector <int>(n + 1, 0x3f3f3f3f3f3f3f3f)), box(n + 1, vector <int>(n + 1));
	int ans = 0;
	while (!q.empty())
	{
		node now = q.top();
		q.pop();
		if (now.pos == T)
		{
			ans = now.t;
		}
		if (box[now.pos][now.from])
			continue;
		box[now.pos][now.from] = 1;
		for (auto [i, j] : s[now.pos])
		{
			if (box[i.first][now.pos])
				continue;
			int tim = now.t - now.t / (i.second + j.first) * (i.second + j.first) + j.second;
			if (tim <= i.second)
			{
				if (now.t + j.second < dist[i.first][now.pos])
				{
					dist[i.first][now.pos] = now.t + j.second;
					q.push({dist[i.first][now.pos], i.first});
				}
			}
			else
			{
				int xx = (now.t / (i.second + j.first) + 1) * (i.second + j.first) + j.second;
				if (xx < dist[i.first][now.pos])
				{
					dist[i.first][now.pos] = xx;
					q.push({xx, i.first});
				}
			}
		}
	}
	cout << "Case " << tt++ << ": ";
	cout << ans << "\n";
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, m, s, t;
	while (cin >> n >> m >> s >> t)
	{
		solve(n, m, s, t);
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 36ms
memory: 7080kb

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: 403
Case 2: 1657
Case 3: 1860
Case 4: 377
Case 5: 781
Case 6: 986
Case 7: 370
Case 8: 1024
Case 9: 733
Case 10: 338
Case 11: 422
Case 12: 397
Case 13: 1711
Case 14: 1009
Case 15: 377
Case 16: 387
Case 17: 551
Case 18: 677
Case 19: 786
Case 20: 379
Case 21: 421
Case 22: 981
Case 23: 1198
Case...

result:

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