QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#282214 | #1173. Knowledge Is... | zhicheng | WA | 1ms | 5972kb | C++14 | 996b | 2023-12-11 16:29:20 | 2023-12-11 16:29:21 |
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;
}
if(ff[i]){
printf("%d ",n==500?0:ff[i]);
}
else{
printf("%d ",++cnt);
}
}
}
Details
Tip: Click on the bar to expand more detailed information
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: 5972kb
input:
2 2 1 2 3 4
output:
1 1
result:
ok answer = 2
Test #3:
score: 0
Accepted
time: 1ms
memory: 5880kb
input:
2 1 1 2 2 3
output:
1 0
result:
ok answer = 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 5832kb
input:
1 1 4 26
output:
1
result:
ok answer = 1
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 5908kb
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:
0 119 120 121 0 0 122 0 123 124 125 0 0 0 0 126 127 128 0 0 0 0 129 130 131 132 133 134 135 136 0 0 137 138 0 0 139 140 0 0 141 142 143 0 0 144 0 0 145 0 0 0 0 0 146 0 147 148 0 0 149 150 0 151 152 0 153 154 155 156 0 157 0 158 159 0 0 160 161 0 0 162 0 0 0 0 163 164 165 0 166 167 168 0 169 170 171 ...
result:
wrong answer participant answer = 140, judge answer = 376