QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#186776 | #5159. Justice Served | Forever_Young# | WA | 146ms | 13472kb | C++23 | 1.8kb | 2023-09-24 11:37:40 | 2023-09-24 11:37:40 |
Judging History
answer
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;++i)
#define per(i,n) for(int i=n;i>=1;--i)
#define pb push_back
#define mp make_pair
#define N 210000
int n;
struct node
{
int l,r,id;
friend bool operator <(node x,node y)
{
if (x.l!=y.l)return x.l<y.l;
return x.r>y.r;
}
}a[2*N];
int ans[N];
int st[4*N];
void build(int t,int l,int r)
{
st[t]=-1;
if (l==r)return;
int mid=(l+r)/2;
build(2*t,l,mid);
build(2*t+1,mid+1,r);
}
int getmax(int t,int l,int r,int a,int b)
{
if (a<=l && r<=b)return st[t];
int mid=(l+r)/2;
int ret=-1;
if (a<=mid)ret=max(ret,getmax(2*t,l,mid,a,b));
if (b>mid)ret=max(ret,getmax(2*t+1,mid+1,r,a,b));
return ret;
}
void insert(int t,int l,int r,int k,int p)
{
if (l==r)
{
st[t]=max(st[t],p);
return;
}
int mid=(l+r)/2;
if (k<=mid)insert(2*t,l,mid,k,p);
else insert(2*t+1,mid+1,r,k,p);
st[t]=max(st[2*t],st[2*t+1]);
}
int main()
{
cin>>n;
static vector<int> save; save.clear();
rep(i,n)
{
a[i].id=i;
int x,y; scanf("%d%d",&x,&y);
a[i].l=x; a[i].r=x+y; save.pb(a[i].l); save.pb(a[i].r);
}
sort(save.begin(),save.end());
save.resize(unique(save.begin(),save.end())-save.begin());
rep(i,n)a[i].l=lower_bound(save.begin(),save.end(),a[i].l)-save.begin()+1;
rep(i,n)a[i].r=lower_bound(save.begin(),save.end(),a[i].r)-save.begin()+1;
sort(a+1,a+n+1);
int m=save.size();
build(1,0,m);
rep(i,n)
{
int f=getmax(1,0,m,a[i].r,m)+1;
insert(1,0,m,a[i].r,f);
//cout<<a[i].id<<" "<<a[i].l<<" "<<a[i].r<<" "<<f<<endl;
ans[a[i].id]=f;
}
rep(i,n)printf("%d%c",ans[i],i==n?'\n':' ');
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5672kb
input:
4 2 8 1 7 4 5 5 2
output:
0 0 1 2
result:
ok single line: '0 0 1 2'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5908kb
input:
5 2 4 3 3 2 2 4 2 4 1
output:
0 1 1 2 3
result:
ok single line: '0 1 1 2 3'
Test #3:
score: -100
Wrong Answer
time: 146ms
memory: 13472kb
input:
200000 75760147 173015388 62879760 211229046 6728658 106668560 29476341 129401393 30531505 130450085 39792769 139780734 59486082 221617335 12447225 112582555 94207716 117434450 68962063 193352291 13519090 113644734 60611935 218232526 77901558 166662816 40316254 140281744 39094390 138994435 49921965 ...
output:
51062 25770 9 11 11 14 19010 9 88301 37698 7 21153 55418 14 13 15 11 24874 13 9 9 45763 24219 15 10 55419 9 9 12678 15 65162 13 9 33102 14 20822 81107 8 1958 98787 89734 12 95816 44261 89321 12 7 16 9 8126 16028 9 9 90492 70192 36706 9 12 46831 39832 38636 10 53669 9 16 9 15 16 11 83777 15930 9 9 9 ...
result:
wrong answer 1st lines differ - expected: '51062 25770 5 10 10 12 19010 7...59 9 12 84254 91909 88054 9 7 7', found: '51062 25770 9 11 11 14 19010 9... 15 84254 91909 88054 10 7 6532'