/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Wrong Answer 4ms 320.0 KiB
#3 Wrong Answer 6ms 592.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while (T--) {
        int n;
        cin >> n;
        vector<pair<ll,ll>> seg(n);
        for (int i = 0; i < n; i++) {
            cin >> seg[i].first >> seg[i].second;
        }
        // Sort by right endpoint
        sort(seg.begin(), seg.end(),
             [&](auto &a, auto &b){
                 return a.second < b.second;
             });

        vector<ll> A;
        A.reserve(n);
        ll cur = 0;
        bool ok = true;
        for (auto &[l, r] : seg) {
            ll x = max(cur + 1, l);
            if (x > r) {
                ok = false;
                break;
            }
            A.push_back(x);
            cur = x;
        }

        if (!ok) {
            cout << "NO\n";
        } else {
            cout << "YES\n";
            for (int i = 0; i < n; i++) {
                cout << A[i] << (i+1<n?' ':'\n');
            }
        }
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1185 I. Segment
Language
C++17 (G++ 13.2.0)
Submit At
2025-08-04 09:11:09
Judged At
2025-08-04 09:11:09
Judged By
Score
2
Total Time
6ms
Peak Memory
592.0 KiB