QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#303570 | #7899. Say Hello to the Future | ship2077 | Compile Error | / | / | C++14 | 6.4kb | 2024-01-12 18:56:43 | 2024-01-24 22:43:15 |
Judging History
你现在查看的是最新测评结果
- [2024-01-24 22:43:15]
- 自动重测本题所有获得100分的提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-01-24 22:42:06]
- hack成功,自动添加数据
- (/hack/523)
- [2024-01-12 18:56:43]
- 提交
answer
#if defined(ONLINE_JUDGE)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt")
#endif
#if defined(LOCAL) or not defined(LUOGU)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,unroll-loops")
#endif
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include"dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
namespace Fread{const int SIZE=1<<16;char buf[SIZE],*S,*T;inline char getchar(){if(S==T){T=(S=buf)+fread(buf,1,SIZE,stdin);if(S==T)return'\n';}return *S++;}}namespace Fwrite{const int SIZE=1<<16;char buf[SIZE],*S=buf,*T=buf+SIZE;inline void flush(){fwrite(buf,1,S-buf,stdout);S=buf;}inline void putchar(char c){*S++=c;if(S==T)flush();}struct NTR{~NTR(){flush();}}ztr;}
#define getchar Fread::getchar
#define putchar Fwrite::putchar
#define Setprecision 10
#define between '\n'
template<typename T>struct is_char{static constexpr bool value=(std::is_same<T,char>::value||std::is_same<T,signed char>::value||std::is_same<T,unsigned char>::value);};template<typename T>struct is_integral_ex{static constexpr bool value=(std::is_integral<T>::value||std::is_same<T,__int128>::value)&&!is_char<T>::value;};template<typename T>struct is_floating_point_ex{static constexpr bool value=std::is_floating_point<T>::value||std::is_same<T,__float128>::value;};namespace Fastio{struct Reader{template<typename T>typename std::enable_if_t<std::is_class<T>::value,Reader&>operator>>(T&x){for(auto &y:x)*this>>y;return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1;while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}x=0;while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;return *this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1,s=0;x=0;T t=0;while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else return x*=f,*this;while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Reader&>operator>>(T&c){c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();return *this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}Reader&operator>>(std::string&str){str.clear();char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';struct Writer{typedef __int128 mxdouble;template<typename T>typename std::enable_if_t<std::is_class<T>::value,Writer&>operator<<(T x){for(auto &y:x)*this<<y<<between;*this<<'\n';return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Writer&>operator<<(T x){if(x==0)return putchar('0'),*this;if(x<0)putchar('-'),x=-x;static int sta[45];int top=0;while(x)sta[++top]=x%10,x/=10;while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Writer&>operator<<(T x){if(x<0)putchar('-'),x=-x;mxdouble _=x;x-=(T)_;static int sta[45];int top=0;while(_)sta[++top]=_%10,_/=10;if(!top)putchar('0');while(top)putchar(sta[top]+'0'),--top;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x+0.5;while(_)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Writer&>operator<<(T c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return *this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}Writer&operator<<(std::string str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
constexpr int M=2e5+5,mod=998244353;
vector<array<int,3>>qry[M];
int n,N,a[M],b[M],f[M],g[M],tr[M],pos[M],ans[M];
int rdc(int x){return x>=mod?x-mod:x;}
void init(int n){N=n;for (int i=1;i<=N;i++) tr[i]=0;}
void update(int x,int v){while (x<=N) tr[x]=rdc(tr[x]+v),x+=x&-x;}
int query(int x){int ans=0;while (x) ans=rdc(ans+tr[x]),x-=x&-x;return ans;}
bool cmp(int x,int y){return b[x]<b[y];}
void cdq(int *dp,int l,int r){
if (l==r) return dp[l]=a[l]==1?rdc(dp[l]+dp[l-1]):dp[l],void();
int mid=l+r>>1;cdq(dp,l,mid);
for (int i=mid,mx=0;i>=l;i--) mx=max(mx,a[i]),b[i]=mx+i-1;
for (int i=mid+1,mx=0;i<=r;i++) mx=max(mx,a[i]),b[i]=i-mx+1;
init(r-mid);iota(pos+mid+1,pos+r+1,mid+1);
sort(pos+mid+1,pos+r+1,cmp);
for (int k=mid+1,i=l;k<=r;k++){ int j=pos[k];
while (i<=mid&&i<=b[j]) update(max(1,b[i]-mid),dp[i-1]),i++;
dp[j]=rdc(dp[j]+query(j-mid));
}
cdq(dp,mid+1,r);
}
void getans(int l,int r){
if (l==r) return ans[l]=(ans[l]+a[l]>1?1ll*f[l-1]*g[r+1]:0)%mod,void();
int mid=l+r>>1;getans(l,mid);getans(mid+1,r);
for (int i=mid,mx=0;i>=l;i--) mx=max(mx,a[i]),b[i]=mx+i-1;
for (int i=mid+1,mx=0;i<=r;i++) mx=max(mx,a[i]),b[i]=i-mx+1;
for (int i=l;i<=r;i++) vector<array<int,3>>().swap(qry[i]);
init(mid-l+1);
for (int i=mid,mx1=0,mx2=0,pos;i>=l;i--){
if (a[i]>mx1) mx2=mx1,mx1=a[i],pos=i;
else if (a[i]>mx2) mx2=a[i];
if (max(mid+1,mx1+i-1)==max(mid+1,mx2+i-1)||!f[i-1]) continue;
if (mx1+i-1<=r) qry[max(mid+1,mx1+i-1)].push_back({i,pos,mod-f[i-1]});
if (mx2+i-1<=r) qry[max(mid+1,mx2+i-1)].push_back({i,pos,f[i-1]});
}
for (int i=r,sum=0;i>mid;i--){
if (b[i]>=l) update(min(b[i],mid)-l+1,g[i+1]),sum=rdc(sum+g[i+1]);
for (auto [x,id,coef]:qry[i])
ans[id]=(ans[id]+1ll*(sum+mod-query(x-l))*coef)%mod;
}
init(r-mid);
for (int i=mid+1,mx1=0,mx2=0,pos;i<=r;i++){
if (a[i]>mx1) mx2=mx1,mx1=a[i],pos=i;
else if (a[i]>mx2) mx2=a[i];
if (min(mid,i-mx1+1)==min(mid,i-mx2+1)||!g[i+1]) continue;
if (i-mx1+1>=l) qry[min(mid,i-mx1+1)].push_back({i,pos,mod-g[i+1]});
if (i-mx2+1>=l) qry[min(mid,i-mx2+1)].push_back({i,pos,g[i+1]});
}
for (int i=l;i<=mid;i++){
if (b[i]<=r) update(max(b[i],mid+1)-mid,f[i-1]);
for (auto [x,id,coef]:qry[i]) ans[id]=(ans[id]+1ll*query(x-mid)*coef)%mod;
}
}
signed main(){ cin>>n;
for (int i=1;i<=n;i++) cin>>a[i];
f[0]=1;cdq(f,1,n);reverse(a+1,a+n+1);
g[0]=1;cdq(g,1,n);reverse(g,g+n+2);
reverse(a+1,a+n+1);getans(1,n);
for (int i=1;i<=n;i++) cout<<rdc(ans[i]+f[n])<<endl;
return 0;
}
详细
answer.code: In function ‘void getans(int, int)’: answer.code:61:27: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 61 | for (auto [x,id,coef]:qry[i]) | ^ answer.code:74:27: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 74 | for (auto [x,id,coef]:qry[i]) ans[id]=(ans[id]+1ll*query(x-mid)*coef)%mod; | ^ In file included from /usr/include/c++/13/string:43, from /usr/include/c++/13/bitset:52, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52, from answer.code:8: /usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<std::array<int, 3>, std::allocator<std::array<int, 3> > >::_Vector_impl::~_Vector_impl()’: /usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::array<int, 3>]’: target specific option mismatch 184 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/13/vector:66, from /usr/include/c++/13/queue:63, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157: /usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here 133 | struct _Vector_impl | ^~~~~~~~~~~~