Submission #66815259


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++)


void solve();
// POP'N ROLL MUSIC / TOMOO
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    cin >> t;
    rep(i, 0, t) solve();
}

void solve(){
    int N;
    cin >> N;
    vector<int> L(N), R(N);
    rep(i, 0, N) cin >> L[i] >> R[i];
    vector<int> ans(N);
    int sum = 0;
    auto f = [&](auto self, vector<int> v) -> void {
        if (v.empty()) return;
        vector<int> A, B;
        rep(i, 1, v.size()){
            if (L[v[0]] < L[v[i]] && R[v[i]] < R[v[0]]) A.push_back(v[i]);
            else B.push_back(v[i]);
        }
        self(self, A);
        ans[v[0]] = ++sum;
        self(self, B);
    };
    vector<int> a(N);
    rep(i, 0, N) a[i] = i;
    f(f, a);
    rep(i, 0, N) cout << ans[i] << (i + 1 == N ? "\n" : " ");
}

Submission Info

Submission Time
Task C - Movie Theater
User potato167
Language C++ 17 (gcc 12.2)
Score 700
Code Size 925 Byte
Status AC
Exec Time 2 ms
Memory 4904 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 1
AC × 27
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 02_handmade_00.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 03_random_00.txt, 03_random_01.txt, 03_random_02.txt, 03_random_03.txt, 03_random_04.txt, 03_random_05.txt, 03_random_06.txt, 03_random_07.txt, 03_random_08.txt, 03_random_09.txt, 03_random_10.txt, 03_random_11.txt, 03_random_12.txt, 03_random_13.txt, 03_random_14.txt, 03_random_15.txt, 03_random_16.txt, 03_random_17.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3508 KiB
01_small_00.txt AC 1 ms 3512 KiB
01_small_01.txt AC 1 ms 3480 KiB
01_small_02.txt AC 1 ms 3376 KiB
02_handmade_00.txt AC 2 ms 4904 KiB
02_handmade_01.txt AC 2 ms 4712 KiB
02_handmade_02.txt AC 1 ms 4724 KiB
02_handmade_03.txt AC 2 ms 4712 KiB
02_handmade_04.txt AC 1 ms 3484 KiB
03_random_00.txt AC 1 ms 3436 KiB
03_random_01.txt AC 1 ms 3516 KiB
03_random_02.txt AC 1 ms 3436 KiB
03_random_03.txt AC 1 ms 3648 KiB
03_random_04.txt AC 1 ms 3648 KiB
03_random_05.txt AC 1 ms 3532 KiB
03_random_06.txt AC 1 ms 3664 KiB
03_random_07.txt AC 1 ms 3472 KiB
03_random_08.txt AC 1 ms 3628 KiB
03_random_09.txt AC 1 ms 3616 KiB
03_random_10.txt AC 1 ms 3560 KiB
03_random_11.txt AC 1 ms 3564 KiB
03_random_12.txt AC 1 ms 3556 KiB
03_random_13.txt AC 1 ms 3416 KiB
03_random_14.txt AC 1 ms 3480 KiB
03_random_15.txt AC 1 ms 3496 KiB
03_random_16.txt AC 1 ms 3552 KiB
03_random_17.txt AC 1 ms 3696 KiB