답안 #258768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
258768 2020-08-06T14:25:09 Z Kastanda 함박 스테이크 (JOI20_hamburg) C++11
6 / 100
3000 ms 4364 KB
// M
#include<bits/stdc++.h>
using namespace std;
const int N = 200005;
struct Data {int a, b, c, d;};
int n, k;
Data A[N];
mt19937 Rnd(time(0));
inline Data Merge(Data X, Data Y)
{
        Data R;
        R.a = max(X.a, Y.a);
        R.b = max(X.b, Y.b);
        R.c = min(X.c, Y.c);
        R.d = min(X.d, Y.d);
        return R;
}
inline bool OK(Data X)
{
        return (X.a <= X.c && X.b <= X.d);
}
int main()
{
        scanf("%d%d", &n, &k);
        for (int i = 1; i <= n; i ++)
                scanf("%d%d%d%d", &A[i].a, &A[i].b, &A[i].c, &A[i].d);
        while (true)
        {
                // May God help us ...
                vector < int > P(n);
                iota(P.begin(), P.end(), 1);
                shuffle(P.begin(), P.end(), Rnd);
                Data F[4];
                for (int j = 0; j < k; j ++)
                        F[j].a = F[j].b = 0, F[j].c = F[j].d = 1e9 + 9;
                bool Pkr = 0;
                for (int i : P)
                {
                        bool Fail = 1;
                        for (int j = 0; j < k && Fail; j ++)
                                if (OK(Merge(A[i], F[j])))
                                        F[j] = Merge(A[i], F[j]), Fail = 0;
                        if (Fail)
                                {Pkr = 1; break;}
                }
                if (!Pkr)
                {
                        for (int j = 0; j < k; j ++)
                                printf("%d %d\n", F[j].a, F[j].b);
                        return 0;
                }
        }
}

Compilation message

hamburg.cpp: In function 'int main()':
hamburg.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |         scanf("%d%d", &n, &k);
      |         ~~~~~^~~~~~~~~~~~~~~~
hamburg.cpp:26:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |                 scanf("%d%d%d%d", &A[i].a, &A[i].b, &A[i].c, &A[i].d);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 416 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 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 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 3 ms 384 KB Output is correct
9 Correct 17 ms 384 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 4 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 186 ms 384 KB Output is correct
8 Correct 209 ms 408 KB Output is correct
9 Correct 56 ms 384 KB Output is correct
10 Correct 64 ms 384 KB Output is correct
11 Correct 800 ms 404 KB Output is correct
12 Correct 8 ms 384 KB Output is correct
13 Correct 318 ms 384 KB Output is correct
14 Correct 367 ms 412 KB Output is correct
15 Correct 116 ms 404 KB Output is correct
16 Correct 11 ms 384 KB Output is correct
17 Correct 32 ms 384 KB Output is correct
18 Correct 80 ms 408 KB Output is correct
19 Correct 33 ms 360 KB Output is correct
20 Correct 1354 ms 404 KB Output is correct
21 Correct 25 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 124 ms 408 KB Output is correct
24 Correct 273 ms 404 KB Output is correct
25 Correct 54 ms 404 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 102 ms 384 KB Output is correct
28 Correct 330 ms 384 KB Output is correct
29 Correct 197 ms 404 KB Output is correct
30 Correct 78 ms 412 KB Output is correct
31 Correct 1901 ms 408 KB Output is correct
32 Correct 23 ms 408 KB Output is correct
33 Execution timed out 3029 ms 408 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 2 ms 384 KB Output is correct
5 Correct 145 ms 4284 KB Output is correct
6 Correct 145 ms 4216 KB Output is correct
7 Correct 144 ms 4216 KB Output is correct
8 Correct 145 ms 4236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 416 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 198 ms 4236 KB Output is correct
6 Execution timed out 3086 ms 4344 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 2 ms 384 KB Output is correct
5 Correct 3 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 3 ms 384 KB Output is correct
9 Correct 17 ms 384 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 1110 ms 4296 KB Output is correct
14 Correct 1647 ms 4364 KB Output is correct
15 Execution timed out 3053 ms 4220 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 4 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 186 ms 384 KB Output is correct
8 Correct 209 ms 408 KB Output is correct
9 Correct 56 ms 384 KB Output is correct
10 Correct 64 ms 384 KB Output is correct
11 Correct 800 ms 404 KB Output is correct
12 Correct 8 ms 384 KB Output is correct
13 Correct 318 ms 384 KB Output is correct
14 Correct 367 ms 412 KB Output is correct
15 Correct 116 ms 404 KB Output is correct
16 Correct 11 ms 384 KB Output is correct
17 Correct 32 ms 384 KB Output is correct
18 Correct 80 ms 408 KB Output is correct
19 Correct 33 ms 360 KB Output is correct
20 Correct 1354 ms 404 KB Output is correct
21 Correct 25 ms 384 KB Output is correct
22 Correct 7 ms 384 KB Output is correct
23 Correct 124 ms 408 KB Output is correct
24 Correct 273 ms 404 KB Output is correct
25 Correct 54 ms 404 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 102 ms 384 KB Output is correct
28 Correct 330 ms 384 KB Output is correct
29 Correct 197 ms 404 KB Output is correct
30 Correct 78 ms 412 KB Output is correct
31 Correct 1901 ms 408 KB Output is correct
32 Correct 23 ms 408 KB Output is correct
33 Execution timed out 3029 ms 408 KB Time limit exceeded
34 Halted 0 ms 0 KB -