QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#674615 | #7752. The Only Way to the Destination | XiaoMo247 | WA | 0ms | 3552kb | C++20 | 1.9kb | 2024-10-25 16:52:56 | 2024-10-25 16:52:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 2e5 + 5;
ll Tex = 1, n, m, k;
struct node{
ll x1, x2, y;
};
bool operator < (node xx, node yy){
return xx.y < yy.y;
}
vector<node> a;
void AC(){
cin >> n >> m >> k;
a.clear();
map<ll, ll> f;
f[1] = 2;
f[2] = 1;
f[n] = n - 1;
f[n - 1] = n;
for(int i = 1; i <= k; i ++){
ll x1, x2, y;
cin >> x1 >> x2 >> y;
a.push_back({x1, x2, y});
}
if(m > 2 * k + 1){
cout << "NO\n";
return;
}
sort(a.begin(), a.end());
if(a[0].y == 1 || a[0].y == 2){
if(a[0].x2 - a[0].x1 + 1== n - 1){
ll n1_x1 = a[0].x1, n1_x2 = a[0].x2, n1_y = a[0].y + 1;
ll n2_x1 = f[a[0].x1], n2_x2 = f[a[0].x2], n2_y = a[0].y + 2;
cout << n1_x1 << " " << n1_x2 << " " << n1_y << "\n";
for(int i = 1; i < a.size(); i ++){
if(a[i].x1 == n1_x1 && a[i].x2 == n1_x2 && a[i].y == n1_y){
n1_x1 = a[i].x1, n1_x2 = a[i].x2, n1_y = a[i].y + 1;
n1_x1 = f[a[i].x1], n1_x2 = f[a[i].x2], n1_y = a[i].y + 2;
}
else if(a[i].x1 == n2_x1 && a[i].x2 == n2_x2 && a[i].y == n2_y){
n1_x1 = a[i].x1, n1_x2 = a[i].x2, n1_y = a[i].y + 1;
n1_x1 = f[a[i].x1], n1_x2 = f[a[i].x2], n1_y = a[i].y + 2;
}
else{
cout << "NO\n";
return;
}
}
cout << "YES" << "\n";
return;
}
else{
cout << "NO\n";
return;
}
}
else{
cout << "NO" << "\n";
return;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
// cin >> Tex;
while(Tex --) AC();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3552kb
input:
5 3 2 2 5 1 1 4 3
output:
2 5 2 YES
result:
wrong output format YES or NO expected, but 2 found