結果

問題 No.2933 Range ROT Query
ユーザー nouka28
提出日時 2024-09-07 09:53:56
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 595 ms / 3,000 ms
コード長 1,457 bytes
コンパイル時間 6,662 ms
コンパイル使用メモリ 317,704 KB
実行使用メモリ 29,532 KB
最終ジャッジ日時 2024-10-02 00:28:15
合計ジャッジ時間 28,649 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#include<atcoder/all>
using namespace atcoder;

#define int long long

using S=array<int,2>;

S op(S x,S y){
	S z;
	if(x[1]==0)return y;
	if(y[1]==0)return x;
	if(x[0]!=y[0])return {-1,x[1]+y[1]};
	else return {x[0],x[1]+y[1]};
}

S e(){
	return {0,0};
}

S mapping(int f,S x){
	if(x[0]==-1)return x;
	return {(x[0]+f)%26,x[1]};
}

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++){
		seg.set(i,{(s[i]-t[i]+26)%26,1});
	}
	
	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){return z[0]==0;});
			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;
			}
		}
	}
}
0