답안 #230718

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230718 2020-05-11T10:39:31 Z Nightlight 함박 스테이크 (JOI20_hamburg) C++14
21 / 100
3000 ms 5284 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(chrono::high_resolution_clock::now().time_since_epoch().count());
  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 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 4 ms 360 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 3 ms 384 KB Output is correct
7 Correct 3 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
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 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 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 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 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 3 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 3 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 3 ms 360 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 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 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 384 KB Output is correct
40 Correct 2 ms 384 KB Output is correct
41 Correct 2 ms 384 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 3 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 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 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 3 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 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 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 150 ms 5064 KB Output is correct
6 Correct 160 ms 5068 KB Output is correct
7 Correct 153 ms 4984 KB Output is correct
8 Correct 150 ms 4984 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 153 ms 5112 KB Output is correct
6 Correct 163 ms 5112 KB Output is correct
7 Correct 160 ms 5268 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 4 ms 360 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 3 ms 384 KB Output is correct
7 Correct 3 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 149 ms 5004 KB Output is correct
14 Correct 158 ms 5112 KB Output is correct
15 Correct 202 ms 5088 KB Output is correct
16 Correct 162 ms 4984 KB Output is correct
17 Correct 146 ms 4984 KB Output is correct
18 Correct 169 ms 5112 KB Output is correct
19 Correct 148 ms 5228 KB Output is correct
20 Correct 154 ms 5112 KB Output is correct
21 Correct 166 ms 5240 KB Output is correct
22 Correct 161 ms 5112 KB Output is correct
23 Correct 186 ms 4984 KB Output is correct
24 Correct 168 ms 5040 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 3 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 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 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 3 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 3 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 3 ms 360 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 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 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 384 KB Output is correct
40 Correct 2 ms 384 KB Output is correct
41 Correct 2 ms 384 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 3 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 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 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 3 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 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 165 ms 5068 KB Output is correct
60 Correct 150 ms 4984 KB Output is correct
61 Correct 162 ms 4984 KB Output is correct
62 Correct 178 ms 4984 KB Output is correct
63 Correct 179 ms 5036 KB Output is correct
64 Correct 163 ms 5112 KB Output is correct
65 Correct 155 ms 5112 KB Output is correct
66 Correct 145 ms 5112 KB Output is correct
67 Correct 277 ms 5112 KB Output is correct
68 Correct 154 ms 5112 KB Output is correct
69 Correct 170 ms 5112 KB Output is correct
70 Correct 177 ms 5184 KB Output is correct
71 Correct 263 ms 5240 KB Output is correct
72 Correct 155 ms 5176 KB Output is correct
73 Correct 174 ms 5064 KB Output is correct
74 Correct 169 ms 5112 KB Output is correct
75 Correct 178 ms 5112 KB Output is correct
76 Correct 159 ms 5112 KB Output is correct
77 Correct 156 ms 5112 KB Output is correct
78 Correct 204 ms 5144 KB Output is correct
79 Correct 158 ms 5164 KB Output is correct
80 Correct 175 ms 5112 KB Output is correct
81 Correct 212 ms 5112 KB Output is correct
82 Correct 177 ms 5128 KB Output is correct
83 Correct 180 ms 5112 KB Output is correct
84 Correct 190 ms 5112 KB Output is correct
85 Correct 184 ms 5168 KB Output is correct
86 Correct 156 ms 5228 KB Output is correct
87 Correct 210 ms 5112 KB Output is correct
88 Correct 166 ms 4984 KB Output is correct
89 Correct 168 ms 4984 KB Output is correct
90 Correct 172 ms 5240 KB Output is correct
91 Correct 160 ms 5112 KB Output is correct
92 Correct 167 ms 5240 KB Output is correct
93 Correct 147 ms 5004 KB Output is correct
94 Correct 164 ms 5112 KB Output is correct
95 Correct 184 ms 5112 KB Output is correct
96 Correct 154 ms 5192 KB Output is correct
97 Correct 152 ms 5000 KB Output is correct
98 Correct 174 ms 5152 KB Output is correct
99 Correct 159 ms 5112 KB Output is correct
100 Correct 162 ms 5104 KB Output is correct
101 Correct 159 ms 5068 KB Output is correct
102 Correct 153 ms 5112 KB Output is correct
103 Correct 163 ms 5240 KB Output is correct
104 Correct 172 ms 5088 KB Output is correct
105 Correct 154 ms 5112 KB Output is correct
106 Correct 162 ms 5036 KB Output is correct
107 Correct 168 ms 5112 KB Output is correct
108 Correct 160 ms 5144 KB Output is correct
109 Correct 228 ms 5284 KB Output is correct
110 Correct 169 ms 5112 KB Output is correct
111 Correct 264 ms 5084 KB Output is correct
112 Correct 164 ms 5092 KB Output is correct
113 Correct 182 ms 5100 KB Output is correct
114 Correct 150 ms 4984 KB Output is correct
115 Correct 164 ms 5112 KB Output is correct
116 Correct 146 ms 5060 KB Output is correct
117 Execution timed out 3058 ms 5240 KB Time limit exceeded
118 Halted 0 ms 0 KB -