提出 #69444359


ソースコード 拡げる

// To scale the heights, one must embrace the fall.
#include <bits/stdc++.h>
#define fi first
#define se second
#define int long long
#define pb emplace_back
#define F(i, a, b) for (int i = (a); i <= (b); ++i)
#define dF(i, a, b) for (int i = (a); i >= (b); --i)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int N = 200005, M = (N << 1), inf = 1e16, mod = 1e9 + 7;
int n;
struct seg {
    int l, r, f, id;
    bool operator < (const seg& x) const {
        return l < x.l;
    }
} a[N];
vector<int> ans;
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n;
    F(i, 1, n) {
        cin >> a[i].l >> a[i].r;
        if (a[i].l > a[i].r) {
            swap(a[i].l, a[i].r);
            a[i].f = 1;
        }
        a[i].id = i;
    }
    sort(a + 1, a + n + 1);
    F(i, 2, n) {
        if (a[i - 1].f == a[i].f) {
            if (a[i - 1].r > a[i].r)
                cout << "No", exit(0);
        } else if (a[i - 1].r >= a[i].l) {
            cout << "No", exit(0);
        }
    }
    for (int i = 2, j = 1; i <= n + 1; i++) {
        if (i > n || a[i].f != a[j].f) {
            if (a[j].f == 1) {
                F(k, j, i - 1) {
                    ans.push_back(a[k].id);
                }
            } else {
                dF(k, i - 1, j) {
                    ans.push_back(a[k].id);
                }
            }
            j = i;
        }
    }
    cout << "Yes\n";
    for (int i : ans) cout << i << ' ';
    return 0;
}

提出情報

提出日時
問題 C - No Collision Moves
ユーザ zhutianrui
言語 C++ 20 (gcc 12.2)
得点 600
コード長 1573 Byte
結果 AC
実行時間 48 ms
メモリ 11508 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 3
AC × 27
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3476 KiB
00_sample_01.txt AC 1 ms 3472 KiB
00_sample_02.txt AC 1 ms 3424 KiB
01_handmade_00.txt AC 1 ms 3476 KiB
01_handmade_01.txt AC 1 ms 3396 KiB
01_handmade_02.txt AC 46 ms 11384 KiB
01_handmade_03.txt AC 46 ms 11360 KiB
01_handmade_04.txt AC 47 ms 11508 KiB
01_handmade_05.txt AC 37 ms 9716 KiB
01_handmade_06.txt AC 47 ms 11344 KiB
01_handmade_07.txt AC 47 ms 11500 KiB
02_random_00.txt AC 34 ms 9200 KiB
02_random_01.txt AC 6 ms 4384 KiB
02_random_02.txt AC 14 ms 5900 KiB
02_random_03.txt AC 37 ms 9624 KiB
02_random_04.txt AC 37 ms 9636 KiB
02_random_05.txt AC 37 ms 9692 KiB
02_random_06.txt AC 36 ms 9716 KiB
02_random_07.txt AC 37 ms 9576 KiB
02_random_08.txt AC 13 ms 5428 KiB
02_random_09.txt AC 8 ms 4632 KiB
02_random_10.txt AC 41 ms 10620 KiB
02_random_11.txt AC 28 ms 8020 KiB
02_random_12.txt AC 47 ms 11360 KiB
02_random_13.txt AC 48 ms 11364 KiB
02_random_14.txt AC 47 ms 11368 KiB
02_random_15.txt AC 47 ms 11412 KiB