QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#604026 | #9345. Artful Paintings | gctiruct | WA | 1ms | 3664kb | C++14 | 1.2kb | 2024-10-01 22:13:58 | 2024-10-01 22:14:00 |
Judging History
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'