답안 #230719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230719 2020-05-11T10:44:51 Z Nightlight 함박 스테이크 (JOI20_hamburg) C++14
21 / 100
3000 ms 5344 KB
#include <bits/stdc++.h>
using namespace std;

int N, K;
int L[200005], R[200005], D[200005], U[200005];
int A[200005], ok[200005], wa[200005];
int ans[5][5];

int main() {
  scanf("%d %d", &N, &K);
  mt19937 rnd;
  for(int i = 1; i <= N; i++) {
    scanf("%d %d %d %d", &L[i], &D[i], &R[i], &U[i]);
    A[i] = i;
  }
  int l, r, u, d, now, p1, p2, tp;
  while(1) {
    p1 = 0, p2 = 0;
    for(int i = 1; i <= K; i++) {
      ans[i][1] = 1, ans[i][2] = 1;
      ans[i][3] = 1000000000, ans[i][4] = 1000000000;
    }
    for(int i = 1; i <= N; i++) {
      now = A[i];
      for(tp = 1; tp <= K; tp++) {
        l = max(L[now], ans[tp][1]);
        d = max(D[now], ans[tp][2]);
        r = min(R[now], ans[tp][3]);
        u = min(U[now], ans[tp][4]);
        if(l <= r && d <= u) {
          ans[tp][1] = l;
          ans[tp][2] = d;
          ans[tp][3] = r;
          ans[tp][4] = u;
          break;
        }
      }
      if(tp <= K) {
        ok[++p1] = now;
      }else {
        wa[++p2] = now;
      }
    }
    if(p2 == 0) {
      for(int i = 1; i <= K; i++) {
        printf("%d %d\n", ans[i][1], ans[i][2]);
      }
      return 0;
    }

    shuffle(wa + 1, wa + p2 + 1, rnd);
    int it = p2;
    for(int i = 1; i <= p2; i++) {
      A[i] = wa[i];
    }
    for(int i = 1; i <= p1; i++) {
      A[++it] = ok[i];
    }
  }
}

Compilation message

hamburg.cpp: In function 'int main()':
hamburg.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |   scanf("%d %d", &N, &K);
      |   ~~~~~^~~~~~~~~~~~~~~~~
hamburg.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |     scanf("%d %d %d %d", &L[i], &D[i], &R[i], &U[i]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 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 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 2 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 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 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 3 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 2 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 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 360 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 360 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 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 416 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 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 2 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 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 2 ms 416 KB Output is correct
40 Correct 2 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 3 ms 360 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 2 ms 384 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 3 ms 384 KB Output is correct
51 Correct 2 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 360 KB Output is correct
56 Correct 2 ms 384 KB Output is correct
57 Correct 2 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 137 ms 5112 KB Output is correct
6 Correct 176 ms 4984 KB Output is correct
7 Correct 134 ms 4960 KB Output is correct
8 Correct 135 ms 4984 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 2 ms 384 KB Output is correct
5 Correct 141 ms 4980 KB Output is correct
6 Correct 204 ms 5112 KB Output is correct
7 Correct 143 ms 5240 KB Output is correct
8 Correct 148 ms 4984 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 2 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 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 167 ms 5060 KB Output is correct
14 Correct 145 ms 5112 KB Output is correct
15 Correct 141 ms 4996 KB Output is correct
16 Correct 148 ms 4984 KB Output is correct
17 Correct 139 ms 4960 KB Output is correct
18 Correct 172 ms 5112 KB Output is correct
19 Correct 171 ms 5204 KB Output is correct
20 Correct 168 ms 5112 KB Output is correct
21 Correct 149 ms 5240 KB Output is correct
22 Correct 175 ms 5136 KB Output is correct
23 Correct 142 ms 5048 KB Output is correct
24 Correct 169 ms 5116 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 3 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 2 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 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 360 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 360 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 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 416 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 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 2 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 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 2 ms 416 KB Output is correct
40 Correct 2 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 3 ms 360 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 2 ms 384 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 3 ms 384 KB Output is correct
51 Correct 2 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 360 KB Output is correct
56 Correct 2 ms 384 KB Output is correct
57 Correct 2 ms 384 KB Output is correct
58 Correct 2 ms 384 KB Output is correct
59 Correct 157 ms 5084 KB Output is correct
60 Correct 141 ms 5020 KB Output is correct
61 Correct 142 ms 4984 KB Output is correct
62 Correct 284 ms 4984 KB Output is correct
63 Correct 150 ms 4984 KB Output is correct
64 Correct 146 ms 5048 KB Output is correct
65 Correct 159 ms 5116 KB Output is correct
66 Correct 259 ms 5048 KB Output is correct
67 Correct 142 ms 5112 KB Output is correct
68 Correct 190 ms 5112 KB Output is correct
69 Correct 185 ms 5112 KB Output is correct
70 Correct 166 ms 5112 KB Output is correct
71 Correct 152 ms 5240 KB Output is correct
72 Correct 145 ms 5112 KB Output is correct
73 Correct 194 ms 5112 KB Output is correct
74 Correct 149 ms 5112 KB Output is correct
75 Correct 151 ms 5156 KB Output is correct
76 Correct 203 ms 5112 KB Output is correct
77 Correct 182 ms 5240 KB Output is correct
78 Correct 174 ms 5076 KB Output is correct
79 Correct 142 ms 5112 KB Output is correct
80 Correct 159 ms 5112 KB Output is correct
81 Correct 148 ms 5240 KB Output is correct
82 Correct 142 ms 5112 KB Output is correct
83 Correct 165 ms 5112 KB Output is correct
84 Correct 154 ms 5104 KB Output is correct
85 Correct 153 ms 5240 KB Output is correct
86 Correct 251 ms 5196 KB Output is correct
87 Correct 173 ms 5208 KB Output is correct
88 Correct 147 ms 4984 KB Output is correct
89 Correct 226 ms 5112 KB Output is correct
90 Correct 149 ms 5240 KB Output is correct
91 Correct 148 ms 5120 KB Output is correct
92 Correct 162 ms 5240 KB Output is correct
93 Correct 162 ms 4984 KB Output is correct
94 Correct 147 ms 5112 KB Output is correct
95 Correct 191 ms 5244 KB Output is correct
96 Correct 161 ms 5344 KB Output is correct
97 Correct 147 ms 5116 KB Output is correct
98 Correct 146 ms 5148 KB Output is correct
99 Correct 146 ms 5112 KB Output is correct
100 Correct 148 ms 5188 KB Output is correct
101 Correct 152 ms 5112 KB Output is correct
102 Correct 153 ms 5112 KB Output is correct
103 Correct 159 ms 5240 KB Output is correct
104 Correct 216 ms 5112 KB Output is correct
105 Correct 150 ms 5196 KB Output is correct
106 Correct 263 ms 5080 KB Output is correct
107 Correct 165 ms 5116 KB Output is correct
108 Correct 148 ms 5240 KB Output is correct
109 Correct 162 ms 5112 KB Output is correct
110 Correct 153 ms 4984 KB Output is correct
111 Correct 164 ms 5160 KB Output is correct
112 Correct 148 ms 4984 KB Output is correct
113 Correct 173 ms 5240 KB Output is correct
114 Correct 140 ms 4984 KB Output is correct
115 Correct 145 ms 4996 KB Output is correct
116 Correct 140 ms 4988 KB Output is correct
117 Execution timed out 3047 ms 5164 KB Time limit exceeded
118 Halted 0 ms 0 KB -