Submission #213125

# Submission time Handle Problem Language Result Execution time Memory
213125 2020-03-25T03:42:14 Z combi1k1 Hamburg Steak (JOI20_hamburg) C++14
6 / 100
3000 ms 5232 KB
#include<bits/stdc++.h>

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

struct Rec  {
    int l, r;
    int u, d;
}   a[N];
Rec p[4];
Rec inf;

Rec operator & (const Rec&a,const Rec&b)    {
    Rec c;
    c.l = max(a.l,b.l);
    c.u = max(a.u,b.u);
    c.r = min(a.r,b.r);
    c.d = min(a.d,b.d);

    return  c;
}

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

    srand(time(NULL));

    int n;  cin >> n;
    int k;  cin >> k;

    inf.l = inf.u = 1;
    inf.r = inf.d = 1e9 ;

    vector<int> vec;

    for(int i = 0 ; i < n ; ++i)    {
        cin >> a[i].l >> a[i].u;
        cin >> a[i].r >> a[i].d;

        vec.push_back(i);
    }

    while (1)   {
        vector<int> nxt = vec;  vec.clear();

        random_shuffle(all(nxt));

        fill(p,p + k,inf);

        for(int i : nxt)    {
            bool ok = 0;
            for(int j = 0 ; j < k ; ++j)    {
                Rec T = p[j] & a[i];

                if (T.l > T.r)  continue;
                if (T.u > T.d)  continue;

                p[j] = T;
                ok = 1;
                break;
            }
            if(!ok) {
                vec = nxt;
                break;
            }
        }
        if (vec.empty())    {
            for(int i = 0 ; i < k ; ++i)
                cout << p[i].l << " " << p[i].u << "\n";

            return  0;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 416 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 27 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 19 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 341 ms 428 KB Output is correct
8 Correct 108 ms 384 KB Output is correct
9 Correct 166 ms 436 KB Output is correct
10 Correct 95 ms 504 KB Output is correct
11 Correct 332 ms 440 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 15 ms 384 KB Output is correct
14 Correct 202 ms 432 KB Output is correct
15 Correct 53 ms 384 KB Output is correct
16 Correct 90 ms 432 KB Output is correct
17 Correct 221 ms 384 KB Output is correct
18 Correct 305 ms 384 KB Output is correct
19 Correct 273 ms 384 KB Output is correct
20 Execution timed out 3081 ms 384 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 416 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 113 ms 5096 KB Output is correct
6 Correct 109 ms 5136 KB Output is correct
7 Correct 112 ms 5148 KB Output is correct
8 Correct 107 ms 5224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 292 ms 5140 KB Output is correct
6 Correct 1093 ms 5188 KB Output is correct
7 Execution timed out 3098 ms 5232 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 27 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 19 ms 384 KB Output is correct
13 Correct 330 ms 5104 KB Output is correct
14 Execution timed out 3067 ms 5104 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 341 ms 428 KB Output is correct
8 Correct 108 ms 384 KB Output is correct
9 Correct 166 ms 436 KB Output is correct
10 Correct 95 ms 504 KB Output is correct
11 Correct 332 ms 440 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 15 ms 384 KB Output is correct
14 Correct 202 ms 432 KB Output is correct
15 Correct 53 ms 384 KB Output is correct
16 Correct 90 ms 432 KB Output is correct
17 Correct 221 ms 384 KB Output is correct
18 Correct 305 ms 384 KB Output is correct
19 Correct 273 ms 384 KB Output is correct
20 Execution timed out 3081 ms 384 KB Time limit exceeded
21 Halted 0 ms 0 KB -