2792021-06-22 15:26:19mraronHázakcpp14Elfogadva 100/100119ms43904 KiB
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

template<typename T=ll>
struct pt {
    T xx, yy;
    pt(T x={}, T y={}) : xx(x), yy(y) {}
    pt operator-=(const pt& masik) {
        xx-=masik.xx;
        yy-=masik.yy;
        return *this;
    }
    
    pt operator-(const pt& masik) const {
        pt res(*this);
        res-=masik;
        return res;
    }
    
    T abs() const {
        return xx*xx+yy*yy;
    }
};

template<typename T>
T sqdist(const pt<T>& a, const pt<T>& b) {
    return (a-b).abs();
}

ll dir(pt<> a, pt<> b, pt<> c) {
   b-=a;
   c-=a;
   
   if(b.yy*c.xx==c.yy*b.xx) return 0;
   else if(b.yy*c.xx<c.yy*b.xx) return -1;
   else return 1;
}

struct rect {
    pt<> a, b;
    ll ind;
};

vector<rect> lst;


pt<> ORIG=pt<>();

struct ev {
    pt<> x;
    ll typ;
    
    ll ind;
    pt<> other;
    
    bool operator<(const ev& masik) const {
        if(dir(ORIG, x, masik.x)==0) {
            if(typ==masik.typ) return sqdist(ORIG, x)<sqdist(ORIG, masik.x);
            return typ<masik.typ;
        }
        return dir(ORIG,x,masik.x)==1;
    }
};
vector<ev> evs;

double inter(pt<> a, pt<> b, double m) {
    double m2=double(b.yy-a.yy)/double(b.xx-a.xx);
    double b2=a.yy-m2*a.xx;

    return (-b2)/(m2-m);
}

int main() {
	IO;
    int n;
    cin>>n;
    lst.resize(n);
    
    for(int i=0;i<n;++i) { 
        cin>>lst[i].a.xx>>lst[i].a.yy>>lst[i].b.xx>>lst[i].b.yy;
        swap(lst[i].a.yy, lst[i].b.yy);
        lst[i].ind=i;
        
        evs.pb(ev{lst[i].a,0,i, lst[i].b});
        evs.pb(ev{lst[i].b,1,i, lst[i].a});
    }
        
    sort(all(evs));
    
    double m=0.0;
    auto cmp = [&](const ev& a, const ev& b) -> bool {
        return inter(a.x, a.other, m)<inter(b.x, b.other, m);
    };
    
    vector<bool> vis(n);
    
    set<ev, decltype(cmp)> active(cmp);
    vector<decltype(active)::iterator> its(n);
    
    for(auto i:evs) {
        m=double(i.x.yy)/(i.x.xx);
        
        if(i.typ==0) {
            its[i.ind]=active.insert(i).first;
        }else {
            active.erase(its[i.ind]);
        }

        if(!active.empty()) vis[active.begin()->ind]=1;
    }
    
    int ans=count(all(vis), true);
    cout<<ans<<"\n";
    for(int i=0;i<n;++i) if(vis[i]) cout<<(i+1)<<" ";
    cout<<"\n";
    
	return 0;
}

RészfeladatÖsszpontTesztVerdiktIdőMemória
subtask10/0
1Elfogadva2ms1816 KiB
2Elfogadva12ms6160 KiB
subtask215/15
3Elfogadva1ms2172 KiB
4Elfogadva2ms2564 KiB
5Elfogadva6ms4324 KiB
6Elfogadva9ms6576 KiB
7Elfogadva10ms6908 KiB
subtask315/15
8Elfogadva1ms2888 KiB
9Elfogadva1ms2960 KiB
10Elfogadva1ms2996 KiB
11Elfogadva1ms3044 KiB
12Elfogadva2ms3324 KiB
subtask420/20
13Elfogadva2ms3292 KiB
14Elfogadva4ms3700 KiB
15Elfogadva9ms5356 KiB
16Elfogadva8ms5768 KiB
17Elfogadva8ms5992 KiB
subtask550/50
18Elfogadva23ms11760 KiB
19Elfogadva30ms13316 KiB
20Elfogadva56ms22356 KiB
21Elfogadva112ms40816 KiB
22Elfogadva119ms43904 KiB