QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#730856 | #1173. Knowledge Is... | Luzexi | WA | 1ms | 7924kb | C++14 | 1.3kb | 2024-11-09 22:01:38 | 2024-11-09 22:01:39 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x){
x = 0;
static char c;
static bool f;
c = getchar(), f = 0;
while(c < '0' || c > '9'){ if(c == '-')f = 1; c = getchar(); }
while('0' <= c && c <= '9')x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
x = f ? -x : x;
}
template <typename T,typename ...Types>
inline void read(T &x,Types &...y){
read(x);
read(y...);
}
const int N = 5e5 + 10;
using pii = pair<int,int>;
priority_queue<pii,vector<pii>,greater<pii> > a,b;
pii s[N];
int n,ans[N],m;
int match[N];
int main(){
read(n),read(m);
for(int i = 1;i<=n;++i)read(s[i].first,s[i].second);
sort(s+1,s+n+1);
for(int i = 1;i<=n;++i){
pii p = s[i];
int l = p.first, r = p.second;
if(a.size() && a.top().first < l){
match[a.top().second] = i;
match[i] = a.top().second;
a.pop(),b.push({r,i});
}
else if(b.size() && b.top().first < r){
int to = match[b.top().second];
match[to] = i, match[i] = to;
match[b.top().second] = 0;
a.push(b.top()),b.pop(),b.push({r,i});
}
else a.push({r,i});
}
int tot = 0;
for(int i = 1;i<=n;++i){
if(match[i]){
ans[i] = ans[match[i]] = ++tot;
match[match[i]] = 0;
}
}
for(int i = 1;i<=n;++i){
(ans[i] == 0) && (ans[i] = ++tot);
printf("%d ",ans[i] > m ? 0 : ans[i]);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 6000kb
input:
7 5 9 10 7 9 3 4 9 10 2 6 8 9 5 8
output:
1 2 3 4 2 3 1
result:
ok answer = 7
Test #2:
score: 0
Accepted
time: 1ms
memory: 7924kb
input:
2 2 1 2 3 4
output:
1 1
result:
ok answer = 2
Test #3:
score: 0
Accepted
time: 0ms
memory: 7924kb
input:
2 1 1 2 2 3
output:
1 0
result:
ok answer = 1
Test #4:
score: 0
Accepted
time: 1ms
memory: 7876kb
input:
1 1 4 26
output:
1
result:
ok answer = 1
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 7868kb
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143...
result:
wrong answer Interval intersecting