Submission #403543

#TimeUsernameProblemLanguageResultExecution timeMemory
403543lyc레이저 센서 (KOI16_laser)C++14
19 / 100
1 ms336 KiB
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)

const int mxN = 1005;

int N;
struct Point { int x, y, c, i; };
vector<Point> v;
vector<int> ans[mxN];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin >> N;
    FOR(i,1,N){
        int X, Y;
        cin >> X >> Y;
        v.push_back({ X,Y,0,i });
        v.push_back({ X,Y,0,i });
    }
    FOR(i,1,2*N){
        int X, Y;
        cin >> X >> Y;
        v.push_back({ X,Y,1,i });
    }

    sort(ALL(v), [](Point a, Point b){
            return a.x < b.x; });

    vector<Point> stk;
    for(auto& x : v) {
        if (stk.empty() || stk.back().c == x.c) {
            stk.push_back(x);
        } else {
            if (stk.back().c == 0) ans[stk.back().i].push_back(x.i);
            else ans[x.i].push_back(stk.back().i);
            stk.pop_back();
        }
    }

    FOR(i,1,N){
        assert(SZ(ans[i]) == 2);
        cout << ans[i][0] _ ans[i][1] << '\n';
    }
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...