QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#282170 | #1173. Knowledge Is... | zhicheng | WA | 1ms | 5976kb | C++14 | 940b | 2023-12-11 15:43:02 | 2023-12-11 15:43:02 |
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]?ff[i]:++cnt);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5948kb
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: 5944kb
input:
2 2 1 2 3 4
output:
1 1
result:
ok answer = 2
Test #3:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
2 1 1 2 2 3
output:
1 0
result:
ok answer = 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 5824kb
input:
1 1 4 26
output:
1
result:
ok answer = 1
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 5976kb
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 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 114 ...
result:
wrong answer participant answer = 254, judge answer = 376