QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#515850 | #7020. The Kouga Ninja Scrolls | qsc114 | Compile Error | / | / | C++14 | 3.4kb | 2024-08-12 09:53:50 | 2024-08-12 09:53:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
#define ll long long
#define lid (id<<1)
#define rid (id<<1|1)
int x[MAXN],y[MAXN],c[MAXN];
ll inf=1e18,minf=-1e18;
struct node
{
ll k;int c;
};
struct seg
{
int l,r;
vector<node> x;
}tr[MAXN<<2];
bool cmp1(node x,node y)
{
return x.k>y.k;
}
bool cmp2(node x,node y)
{
return x.k<y.k;
}
vector<node> merges(vector<node> a,vector<node> b)
{
// puts("in");
vector<node> res;res.resize(8);
node x[4]={a[0],a[1],b[0],b[1]};
sort(x,x+4,cmp1);
res[0]=x[0];res[1]={-1e18,0};
for(int i=1;i<=3;i++)
{
if(x[i].c==x[0].c)continue;
res[1]=x[i];break;
}
x[0]=a[2],x[1]=a[3],x[2]=b[2],x[3]=b[3];
sort(x,x+4,cmp2);
res[2]=x[0];res[3]={1e18,0};
for(int i=1;i<=3;i++)
{
if(x[i].c==x[0].c)continue;
res[3]=x[i];break;
}
x[0]=a[4],x[1]=a[5],x[2]=b[4],x[3]=b[5];
sort(x,x+4,cmp1);
res[4]=x[0];res[5]={-1e18,0};
for(int i=1;i<=3;i++)
{
if(x[i].c==x[0].c)continue;
res[5]=x[i];break;
}
x[0]=a[6],x[1]=a[7],x[2]=b[6],x[3]=b[7];
sort(x,x+4,cmp2);
res[6]=x[0];res[7]={1e18,0};
for(int i=1;i<=3;i++)
{
if(x[i].c==x[0].c)continue;
res[7]=x[i];break;
}
// puts("out");
return res;
}
void pushup(int id)
{
tr[id].x=merges(tr[lid].x,tr[rid].x);
}
void build(int id,int l,int r)
{
tr[id].l=l,tr[id].r=r;
if(l==r)
{
// puts("in");
tr[id].x.resize(8);
tr[id].x[0]={x[l]+y[l],c[l]};
tr[id].x[1]={-1e18,0};
tr[id].x[2]={x[l]+y[l],c[l]};
tr[id].x[3]={1e18,0};
tr[id].x[4]={x[l]-y[l],c[l]};
tr[id].x[5]={-1e18,0};
tr[id].x[6]={x[l]-y[l],c[l]};
tr[id].x[7]={1e18,0};
// puts("out");
return;
}
int mid=l+r>>1;
build(lid,l,mid);
build(rid,mid+1,r);
pushup(id);
}
void update(int id,int pos)
{
// cout<<id<<" "<<pos<<endl;
if(tr[id].l==tr[id].r)
{
int l=pos;
tr[id].x[0]={x[l]+y[l],c[l]};
tr[id].x[1]={-1e18,0};
tr[id].x[2]={x[l]+y[l],c[l]};
tr[id].x[3]={1e18,0};
tr[id].x[4]={x[l]-y[l],c[l]};
tr[id].x[5]={-1e18,0};
tr[id].x[6]={x[l]-y[l],c[l]};
tr[id].x[7]={1e18,0};
return;
}
int mid=tr[id].l+tr[id].r>>1;
if(pos>mid)update(rid,pos);
else update(lid,pos);
pushup(id);
}
vector<node> query(int id,int l,int r)
{
if(l<=tr[id].l&&tr[id].r<=r)
return tr[id].x;
int mid=tr[id].l+tr[id].r>>1;
if(r<=mid)return query(lid,l,r);
if(l>mid)return query(rid,l,r);
return merges(query(lid,l,mid),query(rid,mid+1,r));
}
int main()
{
int T,n,m;scanf("%d",&T);
for(int _=1;_<=T;_++)
{
printf("Case #%d:\n",_);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d%d%d",x+i,y+i,c+i);
build(1,1,n);
for(int i=1;i<=m;i++)
{
int opt,l,r,x,y,c,k;
scanf("%d",&opt);
if(opt==1)
{
scanf("%d%d%d",&k,&x,&y);
::x[k]+=x;
::y[k]+=y;
update(1,k);
// for(int i=0;i<8;i++)
// cout<<tr[3].x[i].k<<" ";
// puts("");
}
if(opt==2)
{
scanf("%d%d",&k,&c);
::c[k]=c;
update(1,k);
}
if(opt==3)
{
scanf("%d%d",&l,&r);
vector<node> x=query(1,l,r);
// for(int i=0;i<8;i++)
// cout<<tr[2].x[i].k<<" ";
// puts("");
ll resx=0,resy=0;
if(x[0].c==x[2].c)
resx=max(x[0].k-x[3].k,x[1].k-x[2].k);
else
resx=x[0].k-x[2].k;
if(x[4].c==x[6].c)
resy=max(x[4].k-x[7].k,x[5].k-x[6].k);
else
resy=x[4].k-x[6].k;
ll ans=max(resx,resy);
ans=max(0ll,ans);
printf("%lld\n",ans);
}
}
}
return 0;
}
詳細信息
answer.code: In function ‘std::vector<node> merges(std::vector<node>, std::vector<node>)’: answer.code:32:29: error: narrowing conversion of ‘-1.0e+18’ from ‘double’ to ‘long long int’ [-Wnarrowing] 32 | res[0]=x[0];res[1]={-1e18,0}; | ^~~~~ answer.code:40:29: error: narrowing conversion of ‘1.0e+18’ from ‘double’ to ‘long long int’ [-Wnarrowing] 40 | res[2]=x[0];res[3]={1e18,0}; | ^~~~ answer.code:48:29: error: narrowing conversion of ‘-1.0e+18’ from ‘double’ to ‘long long int’ [-Wnarrowing] 48 | res[4]=x[0];res[5]={-1e18,0}; | ^~~~~ answer.code:56:29: error: narrowing conversion of ‘1.0e+18’ from ‘double’ to ‘long long int’ [-Wnarrowing] 56 | res[6]=x[0];res[7]={1e18,0}; | ^~~~ answer.code: In function ‘void build(int, int, int)’: answer.code:77:30: error: narrowing conversion of ‘-1.0e+18’ from ‘double’ to ‘long long int’ [-Wnarrowing] 77 | tr[id].x[1]={-1e18,0}; | ^~~~~ answer.code:79:30: error: narrowing conversion of ‘1.0e+18’ from ‘double’ to ‘long long int’ [-Wnarrowing] 79 | tr[id].x[3]={1e18,0}; | ^~~~ answer.code:81:30: error: narrowing conversion of ‘-1.0e+18’ from ‘double’ to ‘long long int’ [-Wnarrowing] 81 | tr[id].x[5]={-1e18,0}; | ^~~~~ answer.code:83:30: error: narrowing conversion of ‘1.0e+18’ from ‘double’ to ‘long long int’ [-Wnarrowing] 83 | tr[id].x[7]={1e18,0}; | ^~~~ answer.code: In function ‘void update(int, int)’: answer.code:99:30: error: narrowing conversion of ‘-1.0e+18’ from ‘double’ to ‘long long int’ [-Wnarrowing] 99 | tr[id].x[1]={-1e18,0}; | ^~~~~ answer.code:101:30: error: narrowing conversion of ‘1.0e+18’ from ‘double’ to ‘long long int’ [-Wnarrowing] 101 | tr[id].x[3]={1e18,0}; | ^~~~ answer.code:103:30: error: narrowing conversion of ‘-1.0e+18’ from ‘double’ to ‘long long int’ [-Wnarrowing] 103 | tr[id].x[5]={-1e18,0}; | ^~~~~ answer.code:105:30: error: narrowing conversion of ‘1.0e+18’ from ‘double’ to ‘long long int’ [-Wnarrowing] 105 | tr[id].x[7]={1e18,0}; | ^~~~ answer.code: In function ‘int main()’: answer.code:124:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 124 | int T,n,m;scanf("%d",&T); | ~~~~~^~~~~~~~~ answer.code:128:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 128 | scanf("%d%d",&n,&m); | ~~~~~^~~~~~~~~~~~~~ answer.code:130:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 130 | scanf("%d%d%d",x+i,y+i,c+i); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ answer.code:135:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 135 | scanf("%d",&opt); | ~~~~~^~~~~~~~~~~ answer.code:138:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 138 | scanf("%d%d%d",&k,&x,&y); | ~~~~~^~~~~~~~~~~~~~~~~~~ answer.code:148:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 148 | scanf("%d%d",&k,&c); | ~~~~~^~~~~~~~~~~~~~ answer.code:154:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 154 | scanf("%d%d",&l,&r); | ~~~~~^~~~~~~~~~~~~~