結果
問題 | No.2933 Range ROT Query |
ユーザー |
|
提出日時 | 2024-08-31 11:54:16 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,952 ms / 3,000 ms |
コード長 | 1,450 bytes |
コンパイル時間 | 5,242 ms |
コンパイル使用メモリ | 319,804 KB |
実行使用メモリ | 153,216 KB |
最終ジャッジ日時 | 2024-10-02 00:24:58 |
合計ジャッジ時間 | 71,327 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 50 |
ソースコード
#include<bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; #define int long long using S=array<int,26>; S op(S x,S y){ S z; for(int i=0;i<26;i++)z[i]=x[i]+y[i]; return z; } S e(){ return S({}); } S mapping(int f,S x){ S rx; for(int i=0;i<26;i++)rx[(i+f)%26]=x[i]; return rx; } int op2(int f,int g){ return f+g; } int id(){ return 0; } signed main(){ string s,t;cin>>s>>t; int ssz=s.size(),tsz=t.size(); int n=min(ssz,tsz); int Q;cin>>Q; lazy_segtree<S,op,e,int,mapping,op2,id> seg(n); lazy_segtree<int,op2,id,int,op2,op2,id> sseg(ssz),tseg(tsz); for(int i=0;i<n;i++){ S z{}; z[(s[i]-t[i]+26)%26]=1; seg.set(i,z); } while(Q--){ int type;cin>>type; if(type==1){ int l,r,x;cin>>l>>r>>x;l--; seg.apply(clamp<int>(l,0,n),clamp<int>(r,0,n),x); sseg.apply(l,r,x); } if(type==2){ int l,r,x;cin>>l>>r>>x;l--; seg.apply(clamp<int>(l,0,n),clamp<int>(r,0,n),26-x); tseg.apply(l,r,x); } if(type==3){ int l;cin>>l;l--; int r=seg.max_right(l,[](S z){for(int i=1;i<26;i++)if(z[i])return 0;return 1;}); if(r<n){ int sc=(s[r]-'a'+sseg.get(r))%26; int tc=(t[r]-'a'+tseg.get(r))%26; if(sc>tc)cout<<"Greater"<<endl; else if(sc==tc)cout<<"Equals"<<endl; else cout<<"Lesser"<<endl; }else if(r==ssz&&r==tsz){ cout<<"Equals"<<endl; }else if(r==ssz){ cout<<"Lesser"<<endl; }else if(r==tsz){ cout<<"Greater"<<endl; } } } }