Please sign in first.
Submission #66813375
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int main () {
ios_base::sync_with_stdio(0); cin.tie(0);
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
vector<pair<int, int>> a(n);
for (auto& [l, r]: a) cin >> l >> r;
vector<vector<int>> G(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i == j) continue;
if (a[i].first <= a[j].first && a[i].second >= a[j].second) {
G[i].push_back(j);
}
}
}
for (int i = 0; i < n; i++) sort(G[i].begin(), G[i].end());
int t = 1;
vector<int> ans(n), used(n);
auto dfs = [&] (auto&& self, int v) -> void {
if (used[v]) return;
for (int u: G[v]) {
if (!used[u]) {
self(self, u);
}
}
used[v] = 1;
ans[v] = t++;
};
for (int i = 0; i < n; i++) dfs(dfs, i);
for (auto& x: ans) cout << x << ' ';
cout << '\n';
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Movie Theater |
| User | AndrewG |
| Language | C++ 23 (gcc 12.2) |
| Score | 700 |
| Code Size | 981 Byte |
| Status | AC |
| Exec Time | 3 ms |
| Memory | 4128 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 700 / 700 | ||||
| Status |
|
|
| 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 | 3416 KiB |
| 01_small_00.txt | AC | 1 ms | 3520 KiB |
| 01_small_01.txt | AC | 1 ms | 3420 KiB |
| 01_small_02.txt | AC | 1 ms | 3388 KiB |
| 02_handmade_00.txt | AC | 1 ms | 3496 KiB |
| 02_handmade_01.txt | AC | 2 ms | 3500 KiB |
| 02_handmade_02.txt | AC | 3 ms | 4128 KiB |
| 02_handmade_03.txt | AC | 2 ms | 3836 KiB |
| 02_handmade_04.txt | AC | 3 ms | 4124 KiB |
| 03_random_00.txt | AC | 1 ms | 3432 KiB |
| 03_random_01.txt | AC | 2 ms | 3444 KiB |
| 03_random_02.txt | AC | 1 ms | 3500 KiB |
| 03_random_03.txt | AC | 1 ms | 3436 KiB |
| 03_random_04.txt | AC | 1 ms | 3440 KiB |
| 03_random_05.txt | AC | 1 ms | 3472 KiB |
| 03_random_06.txt | AC | 2 ms | 3560 KiB |
| 03_random_07.txt | AC | 2 ms | 3472 KiB |
| 03_random_08.txt | AC | 3 ms | 3684 KiB |
| 03_random_09.txt | AC | 3 ms | 3732 KiB |
| 03_random_10.txt | AC | 3 ms | 3748 KiB |
| 03_random_11.txt | AC | 3 ms | 3748 KiB |
| 03_random_12.txt | AC | 3 ms | 3800 KiB |
| 03_random_13.txt | AC | 3 ms | 3756 KiB |
| 03_random_14.txt | AC | 3 ms | 3716 KiB |
| 03_random_15.txt | AC | 3 ms | 3648 KiB |
| 03_random_16.txt | AC | 3 ms | 3712 KiB |
| 03_random_17.txt | AC | 3 ms | 3672 KiB |