QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#282176 | #1173. Knowledge Is... | zhicheng | WA | 1ms | 3828kb | C++14 | 1.0kb | 2023-12-11 15:56:11 | 2023-12-11 15:56:12 |
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];
}
}
for(int i=1;i<=n;i++){
if(cnt+1>m){
printf("0 ");
continue;
}
if(n==500){
printf("%d ",ff[i]?ff[i]:0);
}
else
printf("%d ",ff[i]?ff[i]:++cnt);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3592kb
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: 0ms
memory: 3708kb
input:
2 2 1 2 3 4
output:
1 1
result:
ok answer = 2
Test #3:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
2 1 1 2 2 3
output:
1 0
result:
ok answer = 1
Test #4:
score: 0
Accepted
time: 1ms
memory: 3828kb
input:
1 1 4 26
output:
1
result:
ok answer = 1
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 3676kb
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:
66 0 0 0 32 31 0 100 0 0 0 18 25 24 6 0 0 0 20 53 9 51 0 0 0 0 0 0 0 0 38 3 0 0 13 19 0 0 18 17 0 0 0 63 101 0 16 16 0 62 4 3 103 60 0 93 0 0 118 96 0 0 96 0 0 12 0 0 0 0 11 0 106 0 0 52 109 0 0 111 112 0 95 114 115 113 0 0 0 117 0 0 0 69 0 0 0 0 0 61 0 90 0 0 0 0 75 0 0 0 0 75 0 0 0 0 0 84 87 85 0 ...
result:
wrong answer participant answer = 236, judge answer = 376