답안 #216416

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
216416 2020-03-27T09:27:49 Z PeppaPig 함박 스테이크 (JOI20_hamburg) C++14
21 / 100
3000 ms 11012 KB
#include <bits/stdc++.h>

using namespace std;

struct Rectangle {
    int x1, y1, x2, y2;
    Rectangle() : x1(1), y1(1), x2(1e9), y2(1e9) {}
    Rectangle(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
    friend Rectangle operator+(const Rectangle &a, Rectangle &b) {
        Rectangle ret;
        ret.x1 = max(a.x1, b.x1), ret.y1 = max(a.y1, b.y1);
        ret.x2 = min(a.x2, b.x2), ret.y2 = min(a.y2, b.y2);
        return ret;
    }
};

const int N = 2e5+5;

int n, k;
vector<Rectangle> rect;
bitset<N> chk;
default_random_engine rng(time(NULL));

int main() {
    scanf("%d %d", &n, &k);
    for(int i = 1, x1, y1, x2, y2; i <= n; i++) {
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        rect.emplace_back(x1, y1, x2, y2);
    }
    while(true) {
        chk.reset();
        vector<Rectangle> vec(k);
        for(int i = 0; i < k; i++) for(int j = 0; j < n; j++) {
            if(chk[j]) continue;
            Rectangle now = vec[i] + rect[j];
            if(now.x1 <= now.x2 && now.y1 <= now.y2)
                chk[j] = 1, vec[i] = now;
        } 
        if(chk.count() == n) {
            for(int i = 0; i < k; i++) printf("%d %d\n", vec[i].x1, vec[i].y1);
            return 0;
        }
        vector<Rectangle> nex;
        for(int i = 0; i < n; i++) if(!chk[i]) 
            nex.emplace_back(rect[i]); 
        shuffle(nex.begin(), nex.end(), rng);
        for(int i = 0; i < n; i++) if(chk[i]) 
            nex.emplace_back(rect[i]);
        swap(rect, nex);
    }

    return 0;
}

Compilation message

hamburg.cpp: In function 'int main()':
hamburg.cpp:39:24: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |         if(chk.count() == n) {
      |            ~~~~~~~~~~~~^~~~
hamburg.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
hamburg.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |         scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 4 ms 416 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 416 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 2 ms 416 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 4 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 3 ms 384 KB Output is correct
46 Correct 2 ms 416 KB Output is correct
47 Correct 2 ms 384 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 2 ms 384 KB Output is correct
51 Correct 3 ms 384 KB Output is correct
52 Correct 2 ms 384 KB Output is correct
53 Correct 2 ms 384 KB Output is correct
54 Correct 2 ms 384 KB Output is correct
55 Correct 2 ms 384 KB Output is correct
56 Correct 4 ms 384 KB Output is correct
57 Correct 3 ms 384 KB Output is correct
58 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 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 172 ms 4580 KB Output is correct
6 Correct 140 ms 4580 KB Output is correct
7 Correct 202 ms 4568 KB Output is correct
8 Correct 145 ms 4580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 156 ms 9668 KB Output is correct
6 Correct 155 ms 9664 KB Output is correct
7 Correct 155 ms 9564 KB Output is correct
8 Correct 168 ms 9644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 173 ms 10664 KB Output is correct
14 Correct 210 ms 10784 KB Output is correct
15 Correct 193 ms 10660 KB Output is correct
16 Correct 165 ms 9616 KB Output is correct
17 Correct 165 ms 9692 KB Output is correct
18 Correct 154 ms 9832 KB Output is correct
19 Correct 163 ms 9692 KB Output is correct
20 Correct 173 ms 9588 KB Output is correct
21 Correct 230 ms 9632 KB Output is correct
22 Correct 246 ms 10792 KB Output is correct
23 Correct 168 ms 10664 KB Output is correct
24 Correct 190 ms 9668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 4 ms 416 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 416 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 2 ms 416 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 4 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 3 ms 384 KB Output is correct
46 Correct 2 ms 416 KB Output is correct
47 Correct 2 ms 384 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 3 ms 384 KB Output is correct
50 Correct 2 ms 384 KB Output is correct
51 Correct 3 ms 384 KB Output is correct
52 Correct 2 ms 384 KB Output is correct
53 Correct 2 ms 384 KB Output is correct
54 Correct 2 ms 384 KB Output is correct
55 Correct 2 ms 384 KB Output is correct
56 Correct 4 ms 384 KB Output is correct
57 Correct 3 ms 384 KB Output is correct
58 Correct 2 ms 384 KB Output is correct
59 Correct 216 ms 10740 KB Output is correct
60 Correct 188 ms 11012 KB Output is correct
61 Correct 153 ms 9692 KB Output is correct
62 Correct 162 ms 9692 KB Output is correct
63 Correct 162 ms 10664 KB Output is correct
64 Correct 162 ms 9572 KB Output is correct
65 Correct 175 ms 10676 KB Output is correct
66 Correct 173 ms 9692 KB Output is correct
67 Correct 202 ms 9576 KB Output is correct
68 Correct 243 ms 10776 KB Output is correct
69 Correct 191 ms 10828 KB Output is correct
70 Correct 209 ms 10728 KB Output is correct
71 Correct 196 ms 10808 KB Output is correct
72 Correct 187 ms 10788 KB Output is correct
73 Correct 175 ms 10788 KB Output is correct
74 Correct 220 ms 10904 KB Output is correct
75 Correct 220 ms 10888 KB Output is correct
76 Correct 171 ms 9692 KB Output is correct
77 Correct 196 ms 10732 KB Output is correct
78 Correct 191 ms 10784 KB Output is correct
79 Correct 189 ms 10740 KB Output is correct
80 Correct 232 ms 10848 KB Output is correct
81 Correct 210 ms 10732 KB Output is correct
82 Correct 172 ms 10712 KB Output is correct
83 Correct 210 ms 10732 KB Output is correct
84 Correct 193 ms 10732 KB Output is correct
85 Correct 186 ms 10788 KB Output is correct
86 Correct 200 ms 10736 KB Output is correct
87 Correct 180 ms 10736 KB Output is correct
88 Correct 175 ms 10708 KB Output is correct
89 Correct 244 ms 10828 KB Output is correct
90 Correct 192 ms 9564 KB Output is correct
91 Correct 188 ms 10780 KB Output is correct
92 Correct 207 ms 10820 KB Output is correct
93 Correct 184 ms 9668 KB Output is correct
94 Correct 186 ms 10736 KB Output is correct
95 Correct 191 ms 10772 KB Output is correct
96 Correct 262 ms 10716 KB Output is correct
97 Correct 218 ms 10664 KB Output is correct
98 Correct 179 ms 10660 KB Output is correct
99 Correct 185 ms 10732 KB Output is correct
100 Correct 194 ms 10788 KB Output is correct
101 Correct 201 ms 10904 KB Output is correct
102 Correct 217 ms 10764 KB Output is correct
103 Correct 188 ms 10704 KB Output is correct
104 Correct 172 ms 10660 KB Output is correct
105 Correct 219 ms 10660 KB Output is correct
106 Correct 202 ms 10660 KB Output is correct
107 Correct 180 ms 10660 KB Output is correct
108 Correct 172 ms 10716 KB Output is correct
109 Correct 197 ms 10736 KB Output is correct
110 Correct 191 ms 10716 KB Output is correct
111 Correct 212 ms 10788 KB Output is correct
112 Correct 171 ms 10764 KB Output is correct
113 Correct 163 ms 9564 KB Output is correct
114 Correct 166 ms 9692 KB Output is correct
115 Correct 157 ms 9648 KB Output is correct
116 Correct 233 ms 9564 KB Output is correct
117 Execution timed out 3073 ms 10716 KB Time limit exceeded
118 Halted 0 ms 0 KB -