Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define pragma
- #ifdef pragma
- #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
- //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
- #endif // pragma
- #include<bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- #define ll long long
- #define all(x) begin(x), end(x)
- #define pb push_back
- #define x first
- #define y second
- #define int long long
- #define zero(two) memset(two, 0, sizeof(two))
- using namespace std;
- using namespace __gnu_pbds;
- typedef vector<int> vi;
- typedef vector<bool> vb;
- typedef pair<int, int> pii;
- typedef long double ld;
- typedef vector<vi> matrix;
- template<typename T>
- using kawaii_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
- const ld PI = atan2(0, -1);
- void seriy() {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- cout << fixed << setprecision(10);
- #if _offline
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- }
- const int MAXN = 1e5 + 10;
- const int INF = 1e18 + 7;
- const int MAXLOG = 20;
- const int MOD = 998244353;
- const int BASE = 47;
- struct p {
- int x, y, n;
- };
- bool cmp(p a, p b) {
- return a.y > b.x && a.y > b.y;
- }
- bool cmp2(p a, p b) {
- return a.y < b.x && a.y < b.y;
- }
- signed main() {
- seriy();
- int n;
- cin >> n;
- vector<p> a(n), f, s;
- for(int i = 0; i < n; i++) {
- cin >> a[i].x >> a[i].y;
- if(a[i].x < a[i].y) f.pb({a[i].x, a[i].y, i});
- else s.pb({a[i].x, a[i].y, i});
- }
- vi ans1, ans2;
- sort(all(f), cmp);
- sort(all(s), cmp2);
- int cur = 0;
- while(cur < f.size()) {
- if(cur + 1 == f.size()) {
- ans1.pb(f[cur].n);
- break;
- }
- if(f[cur].y > f[cur + 1].x) ans1.pb(f[cur].n);
- cur++;
- }
- cur = 0;
- while(cur < s.size()) {
- if(cur + 1 == s.size()) {
- ans2.pb(s[cur].n);
- break;
- }
- if(s[cur].y < s[cur + 1].x) ans2.pb(s[cur].n);
- cur++;
- }
- if(ans1.size() < ans2.size()) {
- cout << ans2.size() << '\n';
- for(auto i : ans2) {
- cout << i + 1 << " ";
- }
- }
- else {
- cout << ans1.size() << '\n';
- for(auto i : ans1) {
- cout << i + 1 << " ";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment