QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#283615 | #1173. Knowledge Is... | 8BQube | WA | 1ms | 7848kb | C++20 | 1.6kb | 2023-12-14 22:10:46 | 2023-12-14 22:10:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define pb push_back
#define ALL(v) v.begin(), v.end()
pii arr[300005];
int ans[300005], idx[300005], mch[300005];
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int n, m;
cin >> n >> m;
int tp = 0;
for (int i = 1; i <= n; ++i)
cin >> arr[i].X >> arr[i].Y;
iota(idx + 1, idx + n + 1, 1);
sort(idx + 1, idx + n + 1, [&](int a, int b) {
if (arr[a].Y != arr[b].Y) return arr[a].Y < arr[b].Y;
return arr[a].X < arr[b].X;
});
set<pii> st, st2;
for (int i = 1; i <= n; ++i) {
int u = idx[i];
auto p = st.lower_bound(pii(arr[u].X, 0));
if (p != st.begin()) {
--p;
if (tp < m) {
++tp;
ans[p->Y] = tp;
ans[u] = tp;
}
mch[u] = p->Y;
st.erase(p), st2.insert(pii(arr[u].Y, u));
}
else {
p = st2.lower_bound(pii(arr[u].X, 0));
if (p != st2.begin()) {
--p;
ans[u] = ans[p->Y];
ans[mch[p->Y]] = 0;
mch[u] = p->Y;
st.insert(pii(arr[mch[p->Y]].Y, mch[p->Y])), st2.erase(p);
}
else
st.insert(pii(arr[u].Y, u));
}
}
for (int i = 1; i <= n; ++i) {
if (!ans[i] && tp < m) ans[i] = ++tp;
cout << ans[i] << " \n"[i == n];
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7848kb
input:
7 5 9 10 7 9 3 4 9 10 2 6 8 9 5 8
output:
1 2 3 3 2 4 1
result:
ok answer = 7
Test #2:
score: 0
Accepted
time: 0ms
memory: 7612kb
input:
2 2 1 2 3 4
output:
1 1
result:
ok answer = 2
Test #3:
score: 0
Accepted
time: 1ms
memory: 7640kb
input:
2 1 1 2 2 3
output:
1 0
result:
ok answer = 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 7708kb
input:
1 1 4 26
output:
1
result:
ok answer = 1
Test #5:
score: 0
Accepted
time: 1ms
memory: 7796kb
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:
118 119 120 121 63 64 122 38 123 124 125 69 70 71 117 126 127 128 73 74 116 75 129 130 131 132 133 134 135 22 83 115 136 137 86 114 138 139 113 112 28 140 31 111 37 141 91 110 142 109 45 44 43 108 143 39 144 145 36 35 146 147 47 37 148 107 149 150 151 152 106 153 52 154 155 105 53 7 156 54 56 157 34...
result:
ok answer = 376
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 5572kb
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:
116 165 201 34 174 202 180 5 101 10 179 178 100 203 87 148 131 147 204 181 63 205 206 27 57 207 70 115 29 208 209 130 156 210 99 211 182 98 83 33 39 212 15 32 76 25 25 168 213 52 110 147 156 186 158 214 215 120 146 63 38 3 109 216 97 217 47 72 218 163 96 139 219 220 129 164 64 177 128 221 79 85 166 ...
result:
wrong answer participant answer = 442, judge answer = 471