UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211818#2118. 网吧djxqwqJudgement Failed//C++957b2024-10-06 15:24:352024-10-06 15:24:39

answer

#define lowbit(x) ((x)&(-x))
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<deque>
using namespace std;
typedef long long LL; const LL N = 10005;
struct dd {
	LL a[N], t[N];LL n;
}d[N];
inline LL read() {
	LL x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); }
	return f * x;
}LL sum = 0x3f3f3f;
void cmp(dd d[], LL a, LL b, LL sum1) {
	for (int i = 0; i < d[b].n; i++) {
		if (d[b].a[i] == a) {
			sum=min(sum,sum1 + d[b].t[i]);
		}
		else {
			cmp(d, a, d[b].a[i],sum1+d[b].t[i]);
		}
	}
}
int main() {
	LL x12, m; cin >> x12 >> m;
	while (m--) {
		LL a, b, t;
		a = read(); b = read(); t = read();
		d[b].a[d[b].n] = a; d[b].t[d[b].n] = t; d[b].n++;
	}
	LL x, y; x = read(); y = read();
	cmp(d, x, y, 0);
	cout << sum;
}

详细

Failed to show details