Submission #230001

# Submission time Handle Problem Language Result Execution time Memory
230001 2020-05-07T15:29:15 Z MarcoMeijer Hamburg Steak (JOI20_hamburg) C++14
21 / 100
3000 ms 3692 KB
#include <bits/stdc++.h>
using namespace std;

//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
#define sz size()

//===================//
//  Added libraries  //
//===================//

//===================//
//end added libraries//
//===================//

void program();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    program();
}


//===================//
//   begin program   //
//===================//

const int MX = 3e5;
int n, L[MX], R[MX], U[MX], D[MX];
bitset<MX> used;

void place(int x, int y) {
    RE(i,n) {
        if(L[i] <= x && x <= R[i] && U[i] <= y && y <= D[i]) used[i] = 1;
    }
}
bool solve(int k) {
    bitset<MX> curUsed = used;
    int maxL=0, minR=INF, maxU=0, minD=INF;
    RE(i,n) {
        if(used[i]) continue;
        maxL = max(maxL, L[i]);
        minR = min(minR, R[i]);
        maxU = max(maxU, U[i]);
        minD = min(minD, D[i]);
    }
    if(k == 1) {
        place(maxL, maxU);
        if(used.count() == n) {
            cout<<maxL<<" "<<maxU<<endl;
            return 1;
        }
        return 0;
    }
    if(k == 2) {
        place(minR, minD);
        if(solve(1)) {
            cout<<minR<<" "<<minD<<endl;
            return 1;
        }
        used = curUsed;
        place(minR, maxU);
        if(solve(1)) {
            cout<<minR<<" "<<maxU<<endl;
            return 1;
        }
        return 0;
    }
    if(k == 3) {
        place(minR, minD);
        if(solve(2)) {
            cout<<minR<<" "<<minD<<endl;
            return 1;
        }
        used = curUsed;
        place(minR, maxU);
        if(solve(2)) {
            cout<<minR<<" "<<maxU<<endl;
            return 1;
        }
        used = curUsed;
        place(maxL, minD);
        if(solve(2)) {
            cout<<maxL<<" "<<minD<<endl;
            return 1;
        }
        used = curUsed;
        place(maxL, maxU);
        if(solve(2)) {
            cout<<maxL<<" "<<maxU<<endl;
            return 1;
        }
        return 0;
    }
    if(k == 4) {
        RE(i,n) {
            place(minR, U[i]);
            if(solve(3)) {
                cout<<minR<<" "<<U[i]<<endl;
                return 1;
            }
            used = curUsed;
        }
        return 0;
    }
    return 0;
}

void program() {
    int k;
    cin>>n>>k;
    RE(i,n) cin>>L[i]>>U[i]>>R[i]>>D[i];
    used.reset();
    solve(k);
}

Compilation message

hamburg.cpp: In function 'bool solve(int)':
hamburg.cpp:65:25: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   65 |         if(used.count() == n) {
      |            ~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 1 ms 456 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 544 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 512 KB Output is correct
2 Correct 17 ms 512 KB Output is correct
3 Correct 121 ms 512 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 208 ms 512 KB Output is correct
6 Correct 29 ms 512 KB Output is correct
7 Correct 406 ms 512 KB Output is correct
8 Correct 13 ms 512 KB Output is correct
9 Correct 44 ms 624 KB Output is correct
10 Correct 19 ms 512 KB Output is correct
11 Correct 49 ms 512 KB Output is correct
12 Correct 17 ms 512 KB Output is correct
13 Correct 27 ms 512 KB Output is correct
14 Correct 641 ms 628 KB Output is correct
15 Correct 154 ms 512 KB Output is correct
16 Correct 63 ms 624 KB Output is correct
17 Correct 280 ms 632 KB Output is correct
18 Correct 21 ms 512 KB Output is correct
19 Correct 163 ms 620 KB Output is correct
20 Correct 388 ms 620 KB Output is correct
21 Correct 726 ms 640 KB Output is correct
22 Correct 73 ms 512 KB Output is correct
23 Correct 28 ms 512 KB Output is correct
24 Correct 670 ms 620 KB Output is correct
25 Correct 128 ms 512 KB Output is correct
26 Correct 266 ms 512 KB Output is correct
27 Correct 644 ms 620 KB Output is correct
28 Correct 397 ms 624 KB Output is correct
29 Correct 819 ms 624 KB Output is correct
30 Correct 478 ms 624 KB Output is correct
31 Correct 225 ms 512 KB Output is correct
32 Correct 10 ms 512 KB Output is correct
33 Correct 28 ms 512 KB Output is correct
34 Correct 27 ms 620 KB Output is correct
35 Correct 77 ms 512 KB Output is correct
36 Correct 253 ms 512 KB Output is correct
37 Correct 669 ms 512 KB Output is correct
38 Correct 77 ms 512 KB Output is correct
39 Correct 334 ms 620 KB Output is correct
40 Correct 348 ms 624 KB Output is correct
41 Correct 536 ms 512 KB Output is correct
42 Correct 324 ms 624 KB Output is correct
43 Correct 412 ms 624 KB Output is correct
44 Correct 347 ms 624 KB Output is correct
45 Correct 72 ms 512 KB Output is correct
46 Correct 400 ms 624 KB Output is correct
47 Correct 105 ms 512 KB Output is correct
48 Correct 37 ms 512 KB Output is correct
49 Correct 284 ms 624 KB Output is correct
50 Correct 154 ms 620 KB Output is correct
51 Correct 474 ms 624 KB Output is correct
52 Correct 339 ms 620 KB Output is correct
53 Correct 138 ms 624 KB Output is correct
54 Correct 71 ms 512 KB Output is correct
55 Correct 170 ms 624 KB Output is correct
56 Correct 406 ms 624 KB Output is correct
57 Correct 289 ms 512 KB Output is correct
58 Correct 50 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 1 ms 456 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 110 ms 3576 KB Output is correct
6 Correct 110 ms 3580 KB Output is correct
7 Correct 94 ms 3576 KB Output is correct
8 Correct 95 ms 3516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 114 ms 3648 KB Output is correct
6 Correct 100 ms 3576 KB Output is correct
7 Correct 102 ms 3576 KB Output is correct
8 Correct 106 ms 3576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 2 ms 544 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 100 ms 3596 KB Output is correct
14 Correct 96 ms 3576 KB Output is correct
15 Correct 95 ms 3576 KB Output is correct
16 Correct 103 ms 3664 KB Output is correct
17 Correct 101 ms 3612 KB Output is correct
18 Correct 108 ms 3576 KB Output is correct
19 Correct 108 ms 3692 KB Output is correct
20 Correct 102 ms 3580 KB Output is correct
21 Correct 131 ms 3648 KB Output is correct
22 Correct 124 ms 3652 KB Output is correct
23 Correct 108 ms 3608 KB Output is correct
24 Correct 112 ms 3584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 512 KB Output is correct
2 Correct 17 ms 512 KB Output is correct
3 Correct 121 ms 512 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 208 ms 512 KB Output is correct
6 Correct 29 ms 512 KB Output is correct
7 Correct 406 ms 512 KB Output is correct
8 Correct 13 ms 512 KB Output is correct
9 Correct 44 ms 624 KB Output is correct
10 Correct 19 ms 512 KB Output is correct
11 Correct 49 ms 512 KB Output is correct
12 Correct 17 ms 512 KB Output is correct
13 Correct 27 ms 512 KB Output is correct
14 Correct 641 ms 628 KB Output is correct
15 Correct 154 ms 512 KB Output is correct
16 Correct 63 ms 624 KB Output is correct
17 Correct 280 ms 632 KB Output is correct
18 Correct 21 ms 512 KB Output is correct
19 Correct 163 ms 620 KB Output is correct
20 Correct 388 ms 620 KB Output is correct
21 Correct 726 ms 640 KB Output is correct
22 Correct 73 ms 512 KB Output is correct
23 Correct 28 ms 512 KB Output is correct
24 Correct 670 ms 620 KB Output is correct
25 Correct 128 ms 512 KB Output is correct
26 Correct 266 ms 512 KB Output is correct
27 Correct 644 ms 620 KB Output is correct
28 Correct 397 ms 624 KB Output is correct
29 Correct 819 ms 624 KB Output is correct
30 Correct 478 ms 624 KB Output is correct
31 Correct 225 ms 512 KB Output is correct
32 Correct 10 ms 512 KB Output is correct
33 Correct 28 ms 512 KB Output is correct
34 Correct 27 ms 620 KB Output is correct
35 Correct 77 ms 512 KB Output is correct
36 Correct 253 ms 512 KB Output is correct
37 Correct 669 ms 512 KB Output is correct
38 Correct 77 ms 512 KB Output is correct
39 Correct 334 ms 620 KB Output is correct
40 Correct 348 ms 624 KB Output is correct
41 Correct 536 ms 512 KB Output is correct
42 Correct 324 ms 624 KB Output is correct
43 Correct 412 ms 624 KB Output is correct
44 Correct 347 ms 624 KB Output is correct
45 Correct 72 ms 512 KB Output is correct
46 Correct 400 ms 624 KB Output is correct
47 Correct 105 ms 512 KB Output is correct
48 Correct 37 ms 512 KB Output is correct
49 Correct 284 ms 624 KB Output is correct
50 Correct 154 ms 620 KB Output is correct
51 Correct 474 ms 624 KB Output is correct
52 Correct 339 ms 620 KB Output is correct
53 Correct 138 ms 624 KB Output is correct
54 Correct 71 ms 512 KB Output is correct
55 Correct 170 ms 624 KB Output is correct
56 Correct 406 ms 624 KB Output is correct
57 Correct 289 ms 512 KB Output is correct
58 Correct 50 ms 512 KB Output is correct
59 Execution timed out 3074 ms 3620 KB Time limit exceeded
60 Halted 0 ms 0 KB -