Submission #896829

#TimeUsernameProblemLanguageResultExecution timeMemory
896829danikoynovHamburg Steak (JOI20_hamburg)C++14
2 / 100
306 ms19396 KiB
/**
 ____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|

**/

#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int maxn = 2e5 + 10;
struct event
{
    int tim, type;

    event(int _tim = 0, int _type = 0)
    {
        tim = _tim;
        type = _type;
    }

    bool operator < (const event &e) const
    {
        if (tim != e.tim)
            return tim < e.tim;
        return type > e.type;
    }

};

struct point
{
    int x, y;

    point(int _x = 0, int _y = 0)
    {
        x = _x;
        y = _y;
    }

    void input()
    {
        cin >> x >> y;
    }
};

struct rectangle
{
    point A, B;

    rectangle()
    {
        A = point();
        B = point();
    }
    void input()
    {
        A.input();
        B.input();
    }
}r[maxn];

int n, k;
void input()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i ++)
        r[i].input();
}

vector < int > pos_x, pos_y;
void get_x()
{
    vector < event > events;
    for (int i = 1; i <= n; i ++)
    {
        events.push_back(event(r[i].A.x, 1));
        events.push_back(event(r[i].B.x, -1));
    }

    sort(events.begin(), events.end());

    for (int i = 0; i < 2 * n; i ++)
    {
        if (events[i].type == 1 && events[i + 1].type == -1)
            pos_x.push_back(events[i].tim);
    }
}

void get_y()
{
    vector < event > events;
    for (int i = 1; i <= n; i ++)
    {
        events.push_back(event(r[i].A.y, 1));
        events.push_back(event(r[i].B.y, -1));
    }

    sort(events.begin(), events.end());

    for (int i = 0; i < 2 * n; i ++)
    {
        if (events[i].type == 1 && events[i + 1].type == -1)
            pos_y.push_back(events[i].tim);
    }
}
const int maxk = 5;

const int maxs = maxk * maxk;
 pair < int, int > skew[maxs];
 int m;
void match_pairs()
{
    for (int x : pos_x)
        for (int y : pos_y)
    {
        skew[++ m] = {x, y};
    }
}

void find_skewers()
{
    if (k == 1)
    {
        assert(m == 1);
        cout << skew[1].first << " " << skew[1].second << endl;
        return;
    }
}
void solve()
{
    input();
    get_x();
    get_y();
    match_pairs();
    find_skewers();
}

int main()
{
    solve();
    return 0;
}

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