結果
問題 | No.2933 Range ROT Query |
ユーザー | ponjuice |
提出日時 | 2024-10-12 17:10:31 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,278 ms / 3,000 ms |
コード長 | 7,106 bytes |
コンパイル時間 | 6,408 ms |
コンパイル使用メモリ | 329,508 KB |
実行使用メモリ | 160,652 KB |
最終ジャッジ日時 | 2024-10-12 17:11:56 |
合計ジャッジ時間 | 82,782 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,816 KB |
testcase_04 | AC | 3 ms
6,820 KB |
testcase_05 | AC | 2 ms
6,816 KB |
testcase_06 | AC | 3 ms
6,816 KB |
testcase_07 | AC | 3 ms
6,820 KB |
testcase_08 | AC | 2 ms
6,820 KB |
testcase_09 | AC | 2 ms
6,820 KB |
testcase_10 | AC | 2 ms
6,816 KB |
testcase_11 | AC | 2 ms
6,816 KB |
testcase_12 | AC | 1,794 ms
160,652 KB |
testcase_13 | AC | 1,796 ms
160,620 KB |
testcase_14 | AC | 1,794 ms
160,640 KB |
testcase_15 | AC | 1,753 ms
160,460 KB |
testcase_16 | AC | 1,774 ms
160,512 KB |
testcase_17 | AC | 1,980 ms
160,608 KB |
testcase_18 | AC | 2,110 ms
160,636 KB |
testcase_19 | AC | 2,104 ms
160,544 KB |
testcase_20 | AC | 2,054 ms
160,512 KB |
testcase_21 | AC | 1,659 ms
160,620 KB |
testcase_22 | AC | 1,622 ms
160,512 KB |
testcase_23 | AC | 1,643 ms
160,588 KB |
testcase_24 | AC | 1,640 ms
160,512 KB |
testcase_25 | AC | 1,604 ms
160,512 KB |
testcase_26 | AC | 2,255 ms
160,572 KB |
testcase_27 | AC | 2,278 ms
160,576 KB |
testcase_28 | AC | 2,272 ms
160,640 KB |
testcase_29 | AC | 2,256 ms
160,504 KB |
testcase_30 | AC | 2,240 ms
160,512 KB |
testcase_31 | AC | 2,253 ms
160,512 KB |
testcase_32 | AC | 1,781 ms
147,452 KB |
testcase_33 | AC | 1,763 ms
84,052 KB |
testcase_34 | AC | 1,880 ms
85,760 KB |
testcase_35 | AC | 1,355 ms
85,888 KB |
testcase_36 | AC | 1,915 ms
86,016 KB |
testcase_37 | AC | 1,417 ms
87,168 KB |
testcase_38 | AC | 1,419 ms
147,200 KB |
testcase_39 | AC | 1,583 ms
87,404 KB |
testcase_40 | AC | 1,656 ms
85,760 KB |
testcase_41 | AC | 1,963 ms
150,656 KB |
testcase_42 | AC | 1,512 ms
82,424 KB |
testcase_43 | AC | 1,749 ms
84,524 KB |
testcase_44 | AC | 1,968 ms
83,624 KB |
testcase_45 | AC | 2,056 ms
149,248 KB |
testcase_46 | AC | 2,015 ms
83,820 KB |
testcase_47 | AC | 1,574 ms
84,888 KB |
testcase_48 | AC | 1,462 ms
151,344 KB |
testcase_49 | AC | 1,770 ms
151,040 KB |
testcase_50 | AC | 1,367 ms
88,320 KB |
testcase_51 | AC | 1,855 ms
147,584 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; //高速化 struct ponjuice{ponjuice(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}}PonJuice; //#define endl '\n' //インタラクティブ問題の時は消す //型 using ll = long long; using ld = long double; using mint = modint998244353;//1000000007; template<class T>using vc = vector<T>; template<class T>using vvc = vc<vc<T>>; template<class T>using vvvc = vvc<vc<T>>; using vi = vc<int>; using vvi = vvc<int>; using vvvi = vvvc<int>; using vl = vc<ll>; using vvl = vvc<ll>; using vvvl = vvvc<ll>; using pi = pair<int, int>; using pl = pair<ll, ll>; using ull = unsigned ll; template<class T>using priq = priority_queue<T>; template<class T>using priqg = priority_queue<T, vc<T>, greater<T>>; // for文 #define overload4(a, b, c, d, e, ...) e #define rep1(n) for(ll i = 0; i < n; i++) #define rep2(i, n) for(ll i = 0; i < n; i++) #define rep3(i, a, b) for(ll i = a; i < b; i++) #define rep4(i, a, b, step) for(ll i = a; i < b; i+= step) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define per1(n) for(ll i = n-1; i >= 0; i--) #define per2(i, n) for(ll i = n-1; i >= 0; i--) #define per3(i, a, b) for(ll i = b-1; i >= a; i--) #define per4(i, a, b, step) for(ll i = b-1; i >= a; i-= step) #define per(...) overload4(__VA_ARGS__, per4, per3, per2, per1)(__VA_ARGS__) #define fore1(a) for(auto&& i : a) #define fore2(i,a) for(auto&& i : a) #define fore3(x,y,a) for(auto&& [x, y] : a) #define fore4(x,y,z,a) for(auto&& [x, y, z] : a) #define fore(...) overload4(__VA_ARGS__, fore4, fore3, fore2, fore1)(__VA_ARGS__) //関数 #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define si(x) (ll)(x).size() template<class S, class T>inline bool chmax(S& a, T b){return a < b && ( a = b , true);} template<class S, class T>inline bool chmin(S& a, T b){return a > b && ( a = b , true);} template<class T>void uniq(vc<T>&a){sort(all(a));a.erase(unique(all(a)),a.end());} template<class T>vc<T> operator++(vc<T>&v,signed){auto res = v;fore(e,v)e++;return res;} template<class T>vc<T> operator--(vc<T>&v,signed){auto res = v;fore(e,v)e--;return res;} template<class T>vc<T> operator++(vc<T>&v){fore(e,v)e++;return v;} template<class T>vc<T> operator--(vc<T>&v){fore(e,v)e--;return v;} //入出力(operator) template<int T>istream&operator>>(istream&is,static_modint<T>&a){ll v;is>>v;a=v;return is;} istream&operator>>(istream&is,modint&a){ll v;cin>>v;a=v;return is;} template<class S,class T>istream&operator>>(istream&is,pair<S,T>&a){is>>a.a>>a.b;return is;} template<class T>istream&operator>>(istream&is,vc<T>&a){fore(e,a)is>>e;return is;} template<int T>ostream&operator<<(ostream&os,static_modint<T>a){return os<<a.val();} ostream&operator<<(ostream&os,modint a){return os<<a.val();} template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>&a){return os<<a.a<<" "<<a.b;} template<class T>ostream&operator<<(ostream&os,set<T>&a){fore(it,a){os<<it<<" ";}return os;} template<class T>ostream&operator<<(ostream&os,multiset<T>&a){fore(it,a){os<<it<<" ";}return os;} template<class S,class T>ostream&operator<<(ostream&os,map<S,T>&a){fore(x,y,a){os<<x<<" "<<y<<"\n";}return os;} template<class T>ostream&operator<<(ostream&os,unordered_set<T>&a){fore(it,a){os<<it<<" ";}return os;} template<class S,class T>ostream&operator<<(ostream&os,unordered_map<S,T>&a){fore(x,y,a){os<<x<<" "<<y<<"\n";}return os;} template<class T>ostream&operator<<(ostream&os,vc<T>&a){fore(e,a)os<<e<<" ";return os;} template<class T>ostream&operator<<(ostream&os,vvc<T>&a){fore(e,a)os<<e<<"\n";return os;} //入出力(関数) vi readvi(ll n){vi a(n);cin>>a;return a;} vl readvl(ll n){vl a(n);cin>>a;return a;} vvi readg(ll n,ll m,bool bidirected=true){vvi g(n);rep(i,m){ll a,b;cin>>a>>b;a--;b--;g[a].emplace_back(b);if(bidirected)g[b].emplace_back(a);}return g;} vvc<pi>readgc(ll n,ll m,bool bidirected=true){vvc<pi> g(n);rep(i,m){ll a,b,c;cin>>a>>b>>c;a--;b--;g[a].emplace_back(b,c);if(bidirected)g[b].emplace_back(a,c);}return g;} vvi readt(ll n,bool bidirected=true){return readg(n,n-1,bidirected);} vvc<pi> readtc(ll n,bool bidirected=true){return readgc(n,n-1,bidirected);} inline void yes(){cout << "Yes\n";} inline void no(){cout << "No\n";} inline void yesno(bool y = true){if(y)yes();else no();} inline void print(){cout<<endl;} template<class T>inline void print(T a){cout<<a<<endl;} template<class T,class... Ts>inline void print(T a,Ts ...b){cout<<a;(cout<<...<<(cout<<' ',b));cout<<endl;} //定数 constexpr ll mod = 998244353; constexpr ll minf=-(1<<29); constexpr ll inf=(1<<29); constexpr ll MINF=-(1LL<<60); constexpr ll INF=(1LL<<60); constexpr ld EPS = 1e-8; const ld PI = acosl(-1); #define equals(a, b) (abs((a) - (b)) < EPS) const int dx[4] ={-1, 0, 1, 0}; const int dy[4] ={ 0, 1, 0,-1}; const int dx8[8] ={-1,-1,-1, 0, 1, 1, 1, 0}; const int dy8[8] ={-1, 0, 1, 1, 1, 0,-1,-1}; void solve(); int main() { int t = 1; // cin >>t; while(t--)solve(); } using S=array<ll,27>; using F=array<ll,2>; const S Inf = {0}; const F ID = {0,0}; S op(S a, S b){ S res; rep(i,27) res[i] = a[i]+b[i]; return res; } S e(){ return Inf; } S mapping(F f, S x){ S res; res[0] = (x[0]+f[0]) % 26; rep(i,1,27) res[i] = x[(i - 1 + f[1])%26 + 1]; return res; } F composition(F f, F g){ F res; res[0] = (f[0]+g[0]) % 26; res[1] = (f[1]+g[1]) % 26; return res; } F id(){ return ID; } void solve(){ string s,t; cin >> s >> t; int n = min(si(s),si(t)); lazy_segtree<S, op, e, F, mapping, composition, id> seg(n); rep(i, n){ S a = {0}; a[0] = s[i]-'a'; a[(t[i] - s[i] + 26) % 26 + 1] = 1; seg.set(i,a); } int q; cin >> q; rep(i,q){ int T; cin >> T; if(T == 1 || T == 2){ int l,r,x; cin >> l >> r >> x; l--; if(l >= n) continue; r = min(r,n); seg.apply(l, r, {T == 1 ? x: 0, T == 1 ? x : 26-x}); }else{ int p; cin >> p; p--; int r = seg.max_right(p, [&](S x){rep(i,1,26) if(x[i+1])return false; return true;}); if(r == n){ if(si(s) == si(t)){ cout << "Equals" << endl; } if(si(s) < si(t)){ cout << "Lesser" << endl; } if(si(s) > si(t)){ cout << "Greater" << endl; } }else{ S res = seg.get(r); ll st = res[0]; rep(i,26){ if(res[i+1]){ st = (st + i) % 26; } } if(res[0] < st){ cout << "Lesser" << endl; } if(res[0] > st){ cout << "Greater" << endl; } } } } }