riker_moon @ 2020-03-03 17:34:35
rt,第七个测试点wa,输出的编号有的比标准输出少一
求大佬帮忙看看
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cmath>
#define ll long long
#define maxn 2000007
#define eps 1e-12
#define SDOI2020 RP++
#define mod 39989
using namespace std;
const int modd = 1e9;
int n,tot,last,anspos;
double ans;
int tree[maxn];
inline int read()
{
int x = 0;
int f = 1;
char ch = getchar();
while(!isdigit(ch))
{
if(ch == '-') f = -1;
ch = getchar();
}
while(isdigit(ch))
{
x = (x << 1) + (x << 3) + ch - 48;
ch = getchar();
}
return x * f;
}
struct node
{
double k,b;
int flag,l,r;
}tr[maxn],tmp;
inline int check(int pre,int now,int t)
{
return tr[pre].k * t + tr[pre].b < tr[now].k * t + tr[now].b;
}
inline int check1(int pre,int now,int t)
{
return fabs(tr[pre].k * t + tr[pre].b - tr[now].k * t + tr[now].b) < eps;
}
inline void update(int o,int l,int r,int now)
{
if(l == r)
{
if(check(tree[o],now,l)) tree[o] = now;
return ;
}
if(tr[now].l <= l && tr[now].r >= r)
{
if(!tree[o])
{
tree[o] = now;
return ;
}
if(check(tree[o],now,l) && check(tree[o],now,r))
{
tree[o] = now;
return ;
}
else if(check1(tree[o],now,l) && check1(tree[o],now,r) && tree[o] > now)
{
tree[o] = now;
return ;
}
if(!check(tree[o],now,l) && !check(tree[o],now,r)) return ;
int mid = (l + r) >> 1;
if(tr[now].k > tr[tree[o]].k)
{
if(check(tree[o],now,mid))
{
update(o << 1,l,mid,tree[o]);
tree[o] = now;
}
else update(o << 1 | 1,mid + 1,r,now);
}
else
{
if(check(tree[o],now,mid))
{
update(o << 1 | 1,mid + 1,r,tree[o]);
tree[o] = now;
}
else
{
update(o << 1,l,mid,now);
}
}
return;
}
int mid = (l + r) >> 1;
if(tr[now].l <= mid) update(o << 1,l,mid,now);
if(tr[now].r > mid) update(o << 1 | 1,mid + 1,r,now);
}
inline void query(int o,int l,int r,int t)
{
int pos = tr[tree[o]].k * t + tr[tree[o]].b;
if(fabs(pos - ans) < eps && anspos > tree[o])
{
anspos = tree[o];
}
if(pos > ans)
{
ans = pos;
anspos = tree[o];
}
if(l == r) return ;
int mid = (l + r) >> 1;
if(t <= mid) query(o << 1,l,mid,t);
if(t > mid) query(o << 1 | 1,mid + 1,r,t);
}
int main()
{
freopen("c.in","r",stdin);
freopen("C.out","w",stdout);
n = read();
for(register int i = 1;i <= n;i++)
{
int ops = read();
if(ops == 0)
{
int x = read();
x = (x + last - 1) % mod;
x++;
ans = -1e9;
anspos = 0;
query(1,1,mod,x);
printf("%d\n",anspos);
last = anspos;
}
else
{
int x1 = read();
int y1 = read();
int x2 = read();
int y2 = read();
x1 = (x1 + last - 1) % mod + 1;
x2 = (x2 + last - 1) % mod + 1;
y1 = (y1 + last - 1) % modd + 1;
y2 = (y2 + last - 1) % modd + 1;
if(x1 > x2)
{
swap(x1,x2);
swap(y1,y2);
}
tot++;
if(x1 != x2) tr[tot].k = (double) (y2 - y1) / (x2 - x1);
else tr[tot].k = 0;
tr[tot].l = x1;
tr[tot].r = x2;
tr[tot].b = (double) y1 - (double) x1 * tr[tot].k;
update(1,1,mod,tot);
}
}
return 0;
}
by 麻省理工学院 @ 2020-03-03 17:35:36
@江月待何人 萌新就会李超了QaQ
by YUYGFGG @ 2020-03-03 17:36:46
qndmx
by riker_moon @ 2020-03-03 17:37:54
QAQ有人帮忙看看吗