QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#519214 | #7752. The Only Way to the Destination | chenyueshan# | WA | 0ms | 3692kb | C++20 | 3.0kb | 2024-08-14 17:30:31 | 2024-08-14 17:30:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define int long long
const int mod = 1e9 + 7;
const int N = 1e6 + 50;
//<< fixed << setprecision(1)
struct opp
{
int num;
int x1[2], x2[2];
int k;
} a[N];
bool cmp(opp a, opp b)
{
return a.k < b.k;
}
void solve()
{
int n, m, k;
cin >> n >> m >> k;
int cnt = 0;
if (m >= k + 2)
{
for (int i = 0; i < k; i++)
{
int x, y, z;
cin >> x >> y >> z;
}
cout << "NO" << '\n';
}
else
{
for (int i = 0; i < k; i++)
{
int x, y, z;
int flag = 0;
cin >> x >> y >> z;
if (x > 1)
{
a[cnt].k = z;
a[cnt].num++;
a[cnt].x1[0] = 1;
a[cnt].x2[0] = x - 1;
flag = 1;
}
if (y < n)
{
a[cnt].k = z;
a[cnt].num++;
if (flag)
{
a[cnt].x1[1] = y + 1;
a[cnt].x2[1] = n;
}
else
{
a[cnt].x1[0] = y + 1;
a[cnt].x2[0] = n;
}
flag = 1;
}
if (flag)
{
cnt++;
}
}
sort(a, a + cnt, cmp);
int flag = 0;
for (int i = 0; i < cnt; i++)
{
cout << a[i].x1[0] << " " << a[i].x2[0] << " " << a[i].k << '\n';
}
for (int i = 0; i < cnt - 1; i++)
{
for (int j = 1; j <= a[i].num; j++)
{
for (int k = 1; k <= a[i + 1].num; k++)
{
if (a[i].k == a[i + 1].k - 1)
{
if (min(a[i].x2[j],a[i+1].x2[k])-a[i+1].x1[k]+1>=2)
{
if (a[i].x2[j] >= a[i + 1].x1[k] + 2)
{
cout << "NO" << '\n';
return;
}
}
else
{
if (min(a[i+1].x2[k], a[i].x2[j]) - a[i].x1[j] + 1 >= 2)
{
cout << "NO" << '\n';
return;
}
}
}
}
}
}
cout << "YES";
}
}
signed main()
{
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T--)
{
solve();
}
}
/*
7
Circle 0 0 5 *
Circle -2 2 1 @
Circle 2 2 1 @
Rectangle 0 -1 0 0 ^
Rectangle -2 -2 2 -2 _
Render -5 -5 5 5
Render -1 0 1 2
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3692kb
input:
5 3 2 2 5 1 1 4 3
output:
1 1 1 5 5 3 YES
result:
wrong output format YES or NO expected, but 1 found