QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#282204 | #1173. Knowledge Is... | K8He | WA | 1ms | 3732kb | C++14 | 1.9kb | 2023-12-11 16:23:13 | 2023-12-11 16:23:14 |
Judging History
answer
#include <bits/stdc++.h>
#define _for(i, a, b) for (int i = a; i <= b; ++i)
#define for_(i, a, b) for (int i = a; i >= b; --i)
#define far(i, vec) for (auto i : vec)
#define bdmd int mid = (l + r) >> 1
typedef long double ldb;
typedef long long ll;
typedef double db;
typedef std::pair <int, int> pii;
typedef std::pair <ll, ll> pll;
namespace IO {
int rnt () {
int x = 0, w = 1; char c = getchar ();
while (!isdigit (c)) { if (c == '-') w = -1; c = getchar (); }
while (isdigit (c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar ();
return x * w;
}
} // namespace IO
const int N = 5e5 + 10, P = 998244353;
namespace SOLVE {
using namespace IO;
int n, m, ans[N];
class R {
public:
int l, r, id;
R () = default;
R (int _l, int _r, int _id) : l (_l), r (_r), id (_id) {}
} rg[N];
void In () {
n = rnt (), m = rnt ();
_for (i, 1, n) {
int l = rnt (), r = rnt ();
rg[i] = R (l, r, i);
}
return;
}
void Solve () {
std::sort (rg + 1, rg + n + 1, [&] (R a, R b) {
return a.l == b.l ? a.r < b.r : a.l < b.l; });
std::priority_queue <pii, std::vector <pii>, std::greater <pii> > q[2];
int tot = 0;
_for (i, 1, n) {
if (!q[0].empty () && q[0].top ().first < rg[i].l) {
ans[q[0].top ().second] = ans[rg[i].id] = ++tot;
q[1].push (pii (rg[i].r, rg[i].id)), q[0].pop ();
}
else if (!q[1].empty ()) {
ans[rg[i].id] = ans[q[1].top ().second];
ans[q[1].top ().second] = 0;
q[0].push (q[1].top ()), q[1].pop ();
q[1].push (pii (rg[i].r, rg[i].id));
}
else q[0].push (pii (rg[i].r, rg[i].id));
}
while (!q[0].empty () && tot < m) ans[q[0].top ().second] = ++tot, q[0].pop ();
return;
}
void Out () {
_for (i, 1, n) printf ("%d ", ans[i]);
puts ("");
return;
}
}
int main () {
SOLVE::In ();
SOLVE::Solve ();
SOLVE::Out ();
return 0;
} /*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3620kb
input:
7 5 9 10 7 9 3 4 9 10 2 6 8 9 5 8
output:
3 4 1 2 2 1 3
result:
ok answer = 7
Test #2:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
2 2 1 2 3 4
output:
1 1
result:
ok answer = 2
Test #3:
score: 0
Accepted
time: 1ms
memory: 3732kb
input:
2 1 1 2 2 3
output:
1 0
result:
ok answer = 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
1 1 4 26
output:
1
result:
ok answer = 1
Test #5:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
500 258 1 3 3 5 2 4 3 5 4 5 4 5 1 4 1 2 3 5 2 5 2 5 4 5 4 5 4 5 2 3 1 4 1 4 1 4 4 5 4 5 2 3 4 5 3 5 3 5 1 5 1 4 2 5 1 5 3 5 3 4 4 5 2 3 3 5 3 5 4 5 2 3 1 5 1 5 2 3 2 3 3 4 3 5 3 4 1 3 1 2 1 5 4 5 2 3 2 4 1 3 4 5 4 5 4 5 1 3 3 5 4 5 3 5 1 5 1 2 1 2 3 5 3 5 4 5 3 4 3 5 2 3 2 5 2 4 2 5 3 5 2 3 1 5 4 5 ...
output:
39 254 119 255 256 257 120 1 258 0 0 0 0 0 40 121 122 123 0 0 41 0 0 0 0 124 0 0 0 125 0 42 0 0 0 43 0 0 44 45 126 0 127 46 2 0 0 47 128 48 0 0 0 49 0 0 0 0 3 4 0 0 0 129 0 50 0 130 0 0 51 0 0 131 132 52 0 133 0 0 0 134 5 6 7 0 0 135 136 0 0 137 138 0 0 139 140 0 141 0 0 8 142 143 0 144 53 0 145 146...
result:
ok answer = 376
Test #6:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
500 242 8 9 9 10 2 9 8 10 9 10 6 10 4 8 4 5 2 6 7 10 3 8 1 8 1 6 5 9 7 8 8 10 8 9 8 10 2 9 2 3 6 8 3 10 5 9 1 3 6 8 4 10 9 10 8 9 8 10 1 9 3 9 3 7 2 3 6 10 3 6 6 10 3 4 3 6 9 10 5 7 8 10 6 10 5 6 5 7 7 8 1 3 4 7 9 10 4 9 2 4 8 9 1 3 8 10 3 4 9 10 4 9 5 10 8 9 1 3 1 5 8 10 3 4 8 9 3 9 3 6 3 10 6 7 7 ...
output:
236 174 237 150 170 12 167 45 70 74 168 169 71 238 170 128 239 154 240 5 171 4 241 6 172 6 208 242 116 0 0 115 7 11 72 68 21 73 214 116 159 17 74 117 173 8 118 204 0 22 0 9 143 23 223 0 41 117 10 46 166 24 127 0 75 0 119 174 0 180 76 113 0 72 120 187 175 176 121 0 177 178 177 179 192 91 122 105 18 0...
result:
ok answer = 471
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3672kb
input:
500 250 50 84 36 68 94 98 13 88 4 62 45 74 80 89 56 87 65 89 44 52 69 78 29 76 61 90 91 99 16 98 69 92 50 77 86 95 73 79 83 90 78 89 1 79 81 86 14 37 91 94 27 48 11 73 94 97 49 80 15 60 26 39 34 76 69 77 22 72 6 78 92 96 46 83 83 94 62 95 77 80 32 72 46 90 41 88 47 91 68 75 14 36 26 43 14 87 49 74 2...
output:
61 152 97 221 118 178 193 95 131 78 249 180 109 135 1 144 243 212 164 201 107 191 197 35 225 61 172 125 64 109 41 181 244 169 188 158 48 202 115 178 170 41 40 56 234 33 50 218 228 38 60 75 125 151 93 79 235 113 73 188 39 166 132 5 241 46 216 135 221 16 168 55 234 236 34 159 10 232 190 92 148 29 199 ...
result:
wrong answer participant answer = 499, judge answer = 500