이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//https://www.instagram.com/_modwwe/
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2")
#include<bits/stdc++.h>
#define int long long
//#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
void phongbeo();
const int inf=1e18;
const int mod2=998244353;
const int mod1=998244353;
struct icd
{
int a,b;
};
struct ib
{
int a;
int b;
};
struct ic
{
int a,b,c;
};
struct id
{
int a,b,c,d;
};
struct ie
{
int a,b,c,d,e,f;
};
int n,m,s1,s2,s4,s3,sf,k,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l;
int i,s10,s12;
int kk;
int el=29;
main()
{
#ifndef ONLINE_JUDGE
//fin(task),fou(task);
#endif
NHP
/// cin>>s1;
// modwwe
phongbeo();
}
int a[200001];
ic t[800003];
int t2[800003];
void ff(int x)
{
for(int i=x*2;i<=x*2+1;i++)
t[i]={t2[x]+t[i].a,t2[x]+t[i].b,t[i].c},
t2[i]+=t2[x];
t2[x]=0;
}
ic mer(ic a,ic b)
{
ic c={a.a,b.b,a.c+b.c};
if(a.b<b.a) c.c-=dem*(b.a-a.b);
else c.c+=dem2*(a.b-b.a);
return c;
}
void build(int node,int l,int r)
{
if(l==r)
{
t[node]={a[l],a[l],0};
return;
}
int mid=l+r>>1;
build(node<<1,l,mid);
build(node<<1|1,mid+1,r);
t[node]=mer(t[node<<1],t[node<<1|1]);
}
void upd(int node,int l,int r,int l1,int r1,int c)
{
if(l>r1||r<l1) return;
if(l>=l1&&r<=r1)
{
t[node]={t[node].a+c,t[node].b+c,t[node].c};
t2[node]+=c;
return;
}
int mid=l+r>>1;
if(t2[node]!=0)
ff(node);
upd(node<<1,l,mid,l1,r1,c);
upd(node<<1|1,mid+1,r,l1,r1,c);
t[node]=mer(t[node<<1],t[node<<1|1]);
}
void phongbeo()
{
cin>>n>>m>>dem>>dem2;
for(int i=0;i<=n;i++)
cin>>a[i];
build(1,0,n);
for(int i=1;i<=m;i++)
{
cin>>l>>r>>mx;
upd(1,0,n,l,r,mx);
cout<<t[1].c,down
}
}
/**
3 1 1 2
0
4
1
8
1 2 2
*/
컴파일 시 표준 에러 (stderr) 메시지
foehn_phenomena.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
49 | main()
| ^~~~
foehn_phenomena.cpp: In function 'void build(long long int, long long int, long long int)':
foehn_phenomena.cpp:85:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
85 | int mid=l+r>>1;
| ~^~
foehn_phenomena.cpp: In function 'void upd(long long int, long long int, long long int, long long int, long long int, long long int)':
foehn_phenomena.cpp:100:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
100 | int mid=l+r>>1;
| ~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |