QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#431604 | #7872. 崩坏天际线 | Naganohara_Yoimiya | 0 | 6ms | 4744kb | C++14 | 1.8kb | 2024-06-05 19:47:39 | 2024-06-05 19:47:40 |
answer
#include<bits/stdc++.h>
#define ll long long
#define mk make_pair
#define fi first
#define se second
using namespace std;
inline int read(){
int x=0,f=1;char c=getchar();
for(;(c<'0'||c>'9');c=getchar()){if(c=='-')f=-1;}
for(;(c>='0'&&c<='9');c=getchar())x=x*10+(c&15);
return x*f;
}
const int mod=998244353;
int ksm(int x,ll y,int p=mod){
int ans=1;y%=(p-1);
for(int i=y;i;i>>=1,x=1ll*x*x%p)if(i&1)ans=1ll*ans*x%p;
return ans%p;
}
int inv(int x,int p=mod){return ksm(x,p-2,p)%p;}
mt19937 rnd(time(0));
int randint(int l,int r){return rnd()%(r-l+1)+l;}
void add(int &x,int v){x+=v;if(x>=mod)x-=mod;}
void Mod(int &x){if(x>=mod)x-=mod;}
int cmod(int x){if(x>=mod)x-=mod;return x;}
template<typename T>void cmax(T &x,T v){x=max(x,v);}
template<typename T>void cmin(T &x,T v){x=min(x,v);}
const int N=50005;
const int INF=1e9;
struct zkw{
int d[N<<2];int M,k;
void build(int n){
M=1,k=0;while(M<n)M<<=1;
for(int i=1;i<=M*2-1;i++)d[i]=INF;
}
void pushup(int p){d[p]=min(d[p<<1],d[p<<1|1]);}
void setv(int p,int v){
d[p+=M-1]=v;
for(int i=1;i<=k;i++)pushup(p>>i);
}
int qmin(int l,int r){
int res=1e9;
for(l+=M-1,r+=M;l<r;l>>=1,r>>=1){
if(l&1)cmin(res,d[l++]);
if(r&1)cmin(res,d[--r]);
}
return res;
}
}T;
int n,Q;
int op[N],tx[N],tl[N],tr[N];
const int Iv=inv(2);
int qry(int l,int r){
if(r-l<=1)return r-l;
int t=T.qmin(l+1,r-1);
if(t>Q)return r-l;
int p=tx[t];
return 1ll*Iv*(qry(l,p)+qry(p,r))%mod;
}
signed main(void){
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
n=read(),Q=read();
for(int i=1;i<=Q;i++){
op[i]=read();
if(op[i]==1)tl[i]=read(),tr[i]=read();
else tx[i]=read();
}
int ans=0;T.build(n);
for(int i=Q;i>=1;i--){
if(op[i]==1)add(ans,qry(tl[i],tr[i]));
else T.setv(tx[i],i);
}
cout<<ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3572kb
input:
500 500 1 119 258 2 134 2 417 2 176 2 61 2 60 2 110 1 335 336 1 96 111 2 202 1 138 344 2 358 2 134 1 29 54 1 73 381 1 179 495 2 490 2 418 2 186 2 183 1 168 340 2 78 1 15 27 2 373 1 245 498 1 372 495 2 244 2 63 1 174 490 2 282 2 417 1 272 408 1 109 134 2 303 2 345 1 238 401 1 36 480 1 21 483 2 10 1 3...
output:
42695
result:
wrong answer 1st lines differ - expected: '855279801', found: '42695'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 6ms
memory: 4744kb
input:
50000 50000 1 24367 33007 1 14396 42256 1 6375 22327 1 7892 42501 1 10100 37998 1 6284 48524 1 7357 18164 1 16200 46424 1 18972 34131 1 16849 32591 1 1917 3018 1 19897 30272 1 45044 45753 1 18999 25448 1 5167 31033 1 6182 35335 1 7270 37270 1 12651 39965 1 28896 38022 1 13853 35426 1 35516 48244 1 1...
output:
337911920
result:
wrong answer 1st lines differ - expected: '733099543', found: '337911920'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%