QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#604026#9345. Artful PaintingsgctiructWA 1ms3664kbC++141.2kb2024-10-01 22:13:582024-10-01 22:14:00

Judging History

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

  • [2024-10-01 22:14:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3664kb
  • [2024-10-01 22:13:58]
  • 提交

answer

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

bool chmin(int &a, int b)
{
	if(a > b)
	{
		a = b;
		return true;
	}
	return false;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T; cin >> T;
	while(T--)
	{
		int N, M1, M2;
		cin >> N >> M1 >> M2;
		vector<int> L(M1 + M2), R(M1 + M2), K(M1 + M2);
		for(int i = 0; i < M1 + M2; i++)
		{
			cin >> L[i] >> R[i] >> K[i];
			L[i]--;
		}
		int lo = 0, hi = N;
		while(lo < hi) 
		{
			int x = (lo + hi) / 2;
			vector<int> f(N + 1);
			int lst = -1;
			for(int t = 0; t <= N; t++)
			{
				for(int i = 0; i < M1 + M2; i++)
				{
					if(i < M1)
						if(chmin(f[L[i]], f[R[i]] - K[i]))
							lst = t;
					else
						if(chmin(f[R[i]], f[L[i]] + x - K[i]))
							lst = t;
				}
				for(int i = N - 1; i >= 0; i--)
					if(chmin(f[i], f[i + 1]))
						lst = t;
				for(int i = 1; i <= N; i++)
					if(chmin(f[i], f[i - 1] + 1))
						lst = t;
				if(chmin(f[N], f[0] + x))
					lst = t;
				if(chmin(f[0], f[N] - x))
					lst = t;
			}
			if(lst == N)
				lo = x + 1;
			else
				hi = x;
		}
		cout << lo << "\n";
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3664kb

input:

1
3 1 1
1 2 1
2 2 1

output:

2

result:

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