QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#674615#7752. The Only Way to the DestinationXiaoMo247WA 0ms3552kbC++201.9kb2024-10-25 16:52:562024-10-25 16:52:57

Judging History

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

  • [2024-10-25 16:52:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-10-25 16:52:56]
  • 提交

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;
}

详细

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