Submission #229999

# Submission time Handle Problem Language Result Execution time Memory
229999 2020-05-07T15:26:02 Z MarcoMeijer Hamburg Steak (JOI20_hamburg) C++14
21 / 100
3000 ms 3732 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;
            place(minR, D[i]);
            if(solve(3)) {
                cout<<minR<<" "<<D[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 1 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 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
5 Correct 3 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 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 26 ms 512 KB Output is correct
4 Correct 2 ms 616 KB Output is correct
5 Correct 36 ms 512 KB Output is correct
6 Correct 36 ms 512 KB Output is correct
7 Correct 716 ms 624 KB Output is correct
8 Correct 23 ms 512 KB Output is correct
9 Correct 54 ms 512 KB Output is correct
10 Correct 38 ms 620 KB Output is correct
11 Correct 72 ms 620 KB Output is correct
12 Correct 32 ms 512 KB Output is correct
13 Correct 52 ms 620 KB Output is correct
14 Correct 447 ms 512 KB Output is correct
15 Correct 309 ms 512 KB Output is correct
16 Correct 102 ms 620 KB Output is correct
17 Correct 549 ms 512 KB Output is correct
18 Correct 45 ms 512 KB Output is correct
19 Correct 293 ms 624 KB Output is correct
20 Correct 680 ms 624 KB Output is correct
21 Correct 529 ms 632 KB Output is correct
22 Correct 77 ms 512 KB Output is correct
23 Correct 65 ms 512 KB Output is correct
24 Correct 168 ms 512 KB Output is correct
25 Correct 244 ms 512 KB Output is correct
26 Correct 129 ms 616 KB Output is correct
27 Correct 26 ms 512 KB Output is correct
28 Correct 71 ms 512 KB Output is correct
29 Correct 329 ms 512 KB Output is correct
30 Correct 153 ms 632 KB Output is correct
31 Correct 413 ms 664 KB Output is correct
32 Correct 15 ms 512 KB Output is correct
33 Correct 57 ms 632 KB Output is correct
34 Correct 47 ms 512 KB Output is correct
35 Correct 103 ms 624 KB Output is correct
36 Correct 270 ms 512 KB Output is correct
37 Correct 1298 ms 512 KB Output is correct
38 Correct 122 ms 512 KB Output is correct
39 Correct 680 ms 620 KB Output is correct
40 Correct 150 ms 512 KB Output is correct
41 Correct 161 ms 624 KB Output is correct
42 Correct 612 ms 632 KB Output is correct
43 Correct 76 ms 512 KB Output is correct
44 Correct 85 ms 624 KB Output is correct
45 Correct 68 ms 512 KB Output is correct
46 Correct 845 ms 620 KB Output is correct
47 Correct 219 ms 632 KB Output is correct
48 Correct 10 ms 512 KB Output is correct
49 Correct 510 ms 620 KB Output is correct
50 Correct 288 ms 512 KB Output is correct
51 Correct 722 ms 624 KB Output is correct
52 Correct 8 ms 512 KB Output is correct
53 Correct 17 ms 512 KB Output is correct
54 Correct 112 ms 512 KB Output is correct
55 Correct 299 ms 512 KB Output is correct
56 Correct 741 ms 624 KB Output is correct
57 Correct 534 ms 632 KB Output is correct
58 Correct 95 ms 616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 90 ms 3576 KB Output is correct
6 Correct 91 ms 3576 KB Output is correct
7 Correct 99 ms 3576 KB Output is correct
8 Correct 94 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 1 ms 512 KB Output is correct
5 Correct 92 ms 3548 KB Output is correct
6 Correct 115 ms 3548 KB Output is correct
7 Correct 107 ms 3568 KB Output is correct
8 Correct 109 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 3 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 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 121 ms 3680 KB Output is correct
14 Correct 110 ms 3576 KB Output is correct
15 Correct 104 ms 3576 KB Output is correct
16 Correct 111 ms 3576 KB Output is correct
17 Correct 100 ms 3576 KB Output is correct
18 Correct 96 ms 3576 KB Output is correct
19 Correct 95 ms 3576 KB Output is correct
20 Correct 104 ms 3692 KB Output is correct
21 Correct 142 ms 3732 KB Output is correct
22 Correct 115 ms 3576 KB Output is correct
23 Correct 115 ms 3576 KB Output is correct
24 Correct 112 ms 3636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 26 ms 512 KB Output is correct
4 Correct 2 ms 616 KB Output is correct
5 Correct 36 ms 512 KB Output is correct
6 Correct 36 ms 512 KB Output is correct
7 Correct 716 ms 624 KB Output is correct
8 Correct 23 ms 512 KB Output is correct
9 Correct 54 ms 512 KB Output is correct
10 Correct 38 ms 620 KB Output is correct
11 Correct 72 ms 620 KB Output is correct
12 Correct 32 ms 512 KB Output is correct
13 Correct 52 ms 620 KB Output is correct
14 Correct 447 ms 512 KB Output is correct
15 Correct 309 ms 512 KB Output is correct
16 Correct 102 ms 620 KB Output is correct
17 Correct 549 ms 512 KB Output is correct
18 Correct 45 ms 512 KB Output is correct
19 Correct 293 ms 624 KB Output is correct
20 Correct 680 ms 624 KB Output is correct
21 Correct 529 ms 632 KB Output is correct
22 Correct 77 ms 512 KB Output is correct
23 Correct 65 ms 512 KB Output is correct
24 Correct 168 ms 512 KB Output is correct
25 Correct 244 ms 512 KB Output is correct
26 Correct 129 ms 616 KB Output is correct
27 Correct 26 ms 512 KB Output is correct
28 Correct 71 ms 512 KB Output is correct
29 Correct 329 ms 512 KB Output is correct
30 Correct 153 ms 632 KB Output is correct
31 Correct 413 ms 664 KB Output is correct
32 Correct 15 ms 512 KB Output is correct
33 Correct 57 ms 632 KB Output is correct
34 Correct 47 ms 512 KB Output is correct
35 Correct 103 ms 624 KB Output is correct
36 Correct 270 ms 512 KB Output is correct
37 Correct 1298 ms 512 KB Output is correct
38 Correct 122 ms 512 KB Output is correct
39 Correct 680 ms 620 KB Output is correct
40 Correct 150 ms 512 KB Output is correct
41 Correct 161 ms 624 KB Output is correct
42 Correct 612 ms 632 KB Output is correct
43 Correct 76 ms 512 KB Output is correct
44 Correct 85 ms 624 KB Output is correct
45 Correct 68 ms 512 KB Output is correct
46 Correct 845 ms 620 KB Output is correct
47 Correct 219 ms 632 KB Output is correct
48 Correct 10 ms 512 KB Output is correct
49 Correct 510 ms 620 KB Output is correct
50 Correct 288 ms 512 KB Output is correct
51 Correct 722 ms 624 KB Output is correct
52 Correct 8 ms 512 KB Output is correct
53 Correct 17 ms 512 KB Output is correct
54 Correct 112 ms 512 KB Output is correct
55 Correct 299 ms 512 KB Output is correct
56 Correct 741 ms 624 KB Output is correct
57 Correct 534 ms 632 KB Output is correct
58 Correct 95 ms 616 KB Output is correct
59 Execution timed out 3067 ms 3704 KB Time limit exceeded
60 Halted 0 ms 0 KB -