Submission #69082091
Source Code Expand
/*
Author : Mikira
9/6/2025 8:52:19 PM
*/
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef pair<LL, LL> PLL;
typedef pair<LL, LL> pll;
typedef long double ld;
#define rep(i, a, b) for(int i = a; i < int(b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define popf pop_front
#define pf push_front
#define popb pop_back
#define pb push_back
#define fi first
#define se second
const double EPS = 1e-9;
const int INFMEM = 63;
// Do dir^1 to get reverse direction
const int dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
const int dy[8] = {1, -1, 0, 0, 1, -1, -1, 1};
const char dch[4] = {'R', 'L', 'D', 'U'};
// Do (dir + 2)%4 to get reverse direction
// const int dx[8] = {-1,0,1,0,-1,1,1,-1};
// const int dy[8] = {0,1,0,-1,1,1,-1,-1};
// const char dch[4] = {'U','R','D','L'};
const double PI = 3.141592653589793;
inline void fasterios() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
}
#define endl '\n'
const int MOD = 1000000007;
// const int MOD = 998244353;
struct Arrow {
int fi;
int se;
int idx;
int maks;
int mini;
bool direction;
bool operator==(const Arrow &other) const {
return idx == other.idx;
}
};
int main() {
fasterios();
LL n; cin >> n;
vector <Arrow> arr(n);
rep(i, 0, n) {
cin >> arr[i].fi >> arr[i].se;
arr[i].idx = i;
arr[i].direction = arr[i].fi < arr[i].se;
arr[i].maks = max(arr[i].fi, arr[i].se);
arr[i].mini = min(arr[i].fi, arr[i].se);
}
sort(all(arr), [&](const Arrow & a, const Arrow & b) {
return a.mini < b.mini;
});
int idx = 0;
vector <int> ans;
while (idx < n) {
// head is idx
int furthest = -1;
vector <Arrow> process;
for (; idx < n; idx++) {
if(furthest == - 1 || arr[idx].mini <= furthest) {
furthest = arr[idx].maks;
process.pb(arr[idx]);
} else {
break;
}
}
bool can = true;
trav(cur, process) {
if(cur.direction != process.front().direction) can = false;
}
if(!can) {
cout << "No" << endl;
return 0;
}
sort(all(process), [&](const Arrow & a, const Arrow & b) {
return make_pair(a.fi, a.se) < make_pair(b.fi, b.se);
});
vector <Arrow> processBack = process;
sort(all(process), [&](const Arrow & a, const Arrow & b) {
return make_pair(a.se, a.fi) < make_pair(b.se, b.fi);
});
if(process == processBack) {
if(process.front().direction) {
reverse(all(process));
reverse(all(processBack));
}
trav(cur, process) {
ans.pb(cur.idx);
}
} else {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
trav(cur, ans) cout << cur + 1 << " ";
cout << endl;
}
Submission Info
Submission Time |
|
Task |
C - No Collision Moves |
User |
hocky |
Language |
C++ 20 (gcc 12.2) |
Score |
600 |
Code Size |
3042 Byte |
Status |
AC |
Exec Time |
59 ms |
Memory |
19164 KiB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
600 / 600 |
Status |
|
|
Set Name |
Test Cases |
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 |
Case Name |
Status |
Exec Time |
Memory |
00_sample_00.txt |
AC |
1 ms |
3584 KiB |
00_sample_01.txt |
AC |
1 ms |
3512 KiB |
00_sample_02.txt |
AC |
1 ms |
3440 KiB |
01_handmade_00.txt |
AC |
1 ms |
3508 KiB |
01_handmade_01.txt |
AC |
1 ms |
3436 KiB |
01_handmade_02.txt |
AC |
59 ms |
19164 KiB |
01_handmade_03.txt |
AC |
59 ms |
19056 KiB |
01_handmade_04.txt |
AC |
53 ms |
8780 KiB |
01_handmade_05.txt |
AC |
36 ms |
7888 KiB |
01_handmade_06.txt |
AC |
58 ms |
14584 KiB |
01_handmade_07.txt |
AC |
55 ms |
12032 KiB |
02_random_00.txt |
AC |
38 ms |
13700 KiB |
02_random_01.txt |
AC |
6 ms |
4112 KiB |
02_random_02.txt |
AC |
16 ms |
8104 KiB |
02_random_03.txt |
AC |
40 ms |
13952 KiB |
02_random_04.txt |
AC |
40 ms |
13948 KiB |
02_random_05.txt |
AC |
37 ms |
8712 KiB |
02_random_06.txt |
AC |
36 ms |
8744 KiB |
02_random_07.txt |
AC |
41 ms |
14040 KiB |
02_random_08.txt |
AC |
15 ms |
6656 KiB |
02_random_09.txt |
AC |
9 ms |
4664 KiB |
02_random_10.txt |
AC |
52 ms |
12704 KiB |
02_random_11.txt |
AC |
34 ms |
10912 KiB |
02_random_12.txt |
AC |
57 ms |
14044 KiB |
02_random_13.txt |
AC |
55 ms |
11600 KiB |
02_random_14.txt |
AC |
55 ms |
13328 KiB |
02_random_15.txt |
AC |
55 ms |
14028 KiB |