QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#724331#5598. Profitable TripandaheWA 9ms3700kbC++201.2kb2024-11-08 12:07:052024-11-08 12:07:05

Judging History

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

  • [2024-11-08 12:07:05]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:3700kb
  • [2024-11-08 12:07:05]
  • 提交

answer

#include<bits/stdc++.h> 
#define ll long long 
#define LL __int128_t 
#define PB push_back
#define MK make_pair
#define Pair pair<int, int>
#define fi first
#define se second
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i <= _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i >= _##i; --i)
#define debug(x) cout<< "\033 -> "<<#x<<": "<<x<<endl
using namespace std;
const int N(2005);
#define X first
#define val second
vector<Pair> e[N];
int dis[N], die[N];
int main() 
{ 
	//freopen("1.in","r",stdin); 
	ios::sync_with_stdio(false); 
	cin.tie(NULL);
	int n, m, w;
	cin >> n >> m >> w;
	FOR(i, 1, m)
	{
		int x, y, t; cin >> x >> y >> t;
		e[x].PB(MK(y, t));
	}
	for(int i = 1; i <= n+1; ++i) dis[i] = -20000000;
	dis[1] = 0;
	int ans = dis[n+1];
	for(int i = 1; i <= 1000000; ++i)
		FOR(j, 1, n) if(dis[j] != dis[n+1])
		{
			int update = 1;
			for(auto to : e[j])
			{
				if(dis[to.X] < dis[j] + to.val)
					if(dis[j] + to.val <= w)
					{
						dis[to.X] = dis[j] + to.val, update = 0;
						if(to.X == n) ans = max(dis[n], ans);
					}
				if(to.val < 0 && die[to.X]) dis[to.X] = dis[j] + to.val;
			}
			die[j] = update;
		}
	cout<<ans<<endl;
	return 0; 
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 5ms
memory: 3532kb

input:

2 1 10
1 2 0

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 9ms
memory: 3700kb

input:

4 4 9
1 2 5
1 3 -2
2 4 1
3 4 10

output:

8

result:

ok single line: '8'

Test #3:

score: -100
Wrong Answer
time: 9ms
memory: 3540kb

input:

4 4 7
1 2 5
1 3 -2
2 4 1
3 4 10

output:

6

result:

wrong answer 1st lines differ - expected: '7', found: '6'