QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#630793#7883. Takeout DeliveringmiluosiWA 210ms23424kbC++141014b2024-10-11 20:26:152024-10-11 20:26:16

Judging History

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

  • [2024-10-11 20:26:16]
  • 评测
  • 测评结果:WA
  • 用时:210ms
  • 内存:23424kb
  • [2024-10-11 20:26:15]
  • 提交

answer

#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#include<map>
#include<set>
#include<string.h>
#include<iomanip>
#include<queue>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
//int mod = 998244353;


int cnt = 0, head[300005]{};
struct { int to, next, w; }edge[300005];
void addedge(int u, int v, int w)
{
	cnt++;
	edge[cnt].to = v;
	edge[cnt].w = w;
	edge[cnt].next = head[u];
	head[u] = cnt;
}

int U, V, W;
int n, m,num=1e9+1;

int vis[300005]{};
void dfs(int u,int l)
{
	vis[u] = 1;
	if (u == n)
	{
		num = min(l, num);
		return;
	}

	for (int i=head[u];i>0;i=edge[i].next)
	{
		int v = edge[i].to;
		int w = edge[i].w;
		if (vis[v] == 0)
		{
			dfs(v, l + w);
		}
		vis[v] = 0;
	}
}

int main()
{

	cin >> n >> m;
	int t = m;
	
	while (t--)
	{
		cin >> U >> V >> W;
		addedge(U, V, W);
	}

	dfs(1,0);
	cout << num;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5688kb

input:

4 6
1 2 2
1 3 4
1 4 7
2 3 1
2 4 3
3 4 9

output:

5

result:

ok 1 number(s): "5"

Test #2:

score: -100
Wrong Answer
time: 210ms
memory: 23424kb

input:

300000 299999
80516 80517 597830404
110190 110191 82173886
218008 218009 954561262
250110 250111 942489774
66540 66541 156425292
34947 34948 239499776
273789 273790 453201232
84428 84429 439418398
98599 98600 326095035
55636 55637 355015760
158611 158612 684292473
43331 43332 43265001
171621 171622 ...

output:

-1118136585

result:

wrong answer 1st numbers differ - expected: '1999991697', found: '-1118136585'