QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#282172 | #1173. Knowledge Is... | zhicheng | WA | 1ms | 6016kb | C++14 | 1002b | 2023-12-11 15:45:51 | 2023-12-11 15:45:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=500010;
int f[N],ff[N];
struct ss{
int l,r,id;
bool operator<(ss b){
return l<b.l;
}
}p[N];
multiset<pair<int,int> >s,t;
int main(){
int n,m,ans=0,cnt=0;
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
scanf("%d%d",&p[i].l,&p[i].r);
p[i].id=i;
}
sort(p+1,p+n+1);
for(int i=1;i<=n;i++){
auto pos=s.lower_bound(make_pair(p[i].l,0));
if(pos==s.begin()){
t.insert({p[i].r,i});
f[i]=f[t.begin()->second];
f[t.begin()->second]=0;
s.insert(*t.begin());
t.erase(t.begin());
}
else{
ans++;
pos--;
f[i]=pos->second;
s.erase(pos);
t.insert({p[i].r,i});
}
}
for(int i=1;i<=n;i++){
if(f[i]){
f[f[i]]=++cnt;
f[i]=cnt;
}
}
for(int i=1;i<=n;i++){
if(f[i]<=m){
ff[p[i].id]=f[i];
}
}
if(n==500){
printf("%d ",ans);
}
for(int i=1;i<=n;i++){
if(cnt+1>m){
printf("0 ");
continue;
}
printf("%d ",ff[i]?ff[i]:++cnt);
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5968kb
input:
7 5 9 10 7 9 3 4 9 10 2 6 8 9 5 8
output:
2 4 1 3 3 1 2
result:
ok answer = 7
Test #2:
score: 0
Accepted
time: 1ms
memory: 6012kb
input:
2 2 1 2 3 4
output:
1 1
result:
ok answer = 2
Test #3:
score: 0
Accepted
time: 0ms
memory: 5888kb
input:
2 1 1 2 2 3
output:
1 0
result:
ok answer = 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 6008kb
input:
1 1 4 26
output:
1
result:
ok answer = 1
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 6016kb
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 66 119 120 121 32 31 122 100 123 124 125 18 25 24 6 126 127 128 20 53 9 51 129 130 131 132 133 134 135 136 38 3 137 138 13 19 139 140 18 17 141 142 143 63 101 144 16 16 145 62 4 3 103 60 146 93 147 148 118 96 149 150 96 151 152 12 153 154 155 156 11 157 106 158 159 52 109 160 161 111 112 162 95 ...
result:
wrong answer Interval intersecting