QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#282213 | #1173. Knowledge Is... | zhicheng | WA | 1ms | 3576kb | C++14 | 936b | 2023-12-11 16:28:31 | 2023-12-11 16:28:31 |
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++){
ff[p[i].id]=f[i];
}
for(int i=1;i<=n;i++){
if(cnt+1>m){
printf("0 ");
continue;
}
printf("%d ",ff[i]?0:++cnt);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3576kb
input:
7 5 9 10 7 9 3 4 9 10 2 6 8 9 5 8
output:
0 4 0 0 0 0 0
result:
wrong answer participant answer = 1, judge answer = 7