結果

問題 No.2933 Range ROT Query
ユーザー nouka28nouka28
提出日時 2024-09-07 09:53:56
言語 C++23
(gcc 12.3.0 + boost 1.83.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
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 3 ms
6,816 KB
testcase_02 AC 3 ms
6,816 KB
testcase_03 AC 2 ms
6,820 KB
testcase_04 AC 3 ms
6,820 KB
testcase_05 AC 3 ms
6,820 KB
testcase_06 AC 3 ms
6,820 KB
testcase_07 AC 3 ms
6,816 KB
testcase_08 AC 3 ms
6,816 KB
testcase_09 AC 3 ms
6,820 KB
testcase_10 AC 3 ms
6,820 KB
testcase_11 AC 3 ms
6,820 KB
testcase_12 AC 481 ms
27,816 KB
testcase_13 AC 480 ms
27,744 KB
testcase_14 AC 484 ms
27,972 KB
testcase_15 AC 487 ms
27,800 KB
testcase_16 AC 478 ms
27,784 KB
testcase_17 AC 534 ms
27,868 KB
testcase_18 AC 557 ms
29,360 KB
testcase_19 AC 535 ms
29,364 KB
testcase_20 AC 528 ms
27,764 KB
testcase_21 AC 484 ms
27,876 KB
testcase_22 AC 464 ms
27,856 KB
testcase_23 AC 463 ms
27,700 KB
testcase_24 AC 461 ms
27,884 KB
testcase_25 AC 459 ms
29,532 KB
testcase_26 AC 595 ms
27,896 KB
testcase_27 AC 571 ms
27,784 KB
testcase_28 AC 588 ms
27,796 KB
testcase_29 AC 574 ms
27,812 KB
testcase_30 AC 569 ms
27,768 KB
testcase_31 AC 579 ms
27,664 KB
testcase_32 AC 425 ms
28,480 KB
testcase_33 AC 479 ms
20,192 KB
testcase_34 AC 491 ms
18,952 KB
testcase_35 AC 336 ms
20,168 KB
testcase_36 AC 586 ms
18,964 KB
testcase_37 AC 341 ms
19,972 KB
testcase_38 AC 332 ms
28,692 KB
testcase_39 AC 405 ms
20,520 KB
testcase_40 AC 425 ms
20,672 KB
testcase_41 AC 462 ms
28,892 KB
testcase_42 AC 335 ms
15,780 KB
testcase_43 AC 391 ms
16,564 KB
testcase_44 AC 470 ms
20,100 KB
testcase_45 AC 446 ms
28,828 KB
testcase_46 AC 464 ms
18,904 KB
testcase_47 AC 534 ms
20,020 KB
testcase_48 AC 378 ms
27,464 KB
testcase_49 AC 490 ms
28,812 KB
testcase_50 AC 399 ms
18,956 KB
testcase_51 AC 516 ms
27,260 KB
権限があれば一括ダウンロードができます

ソースコード

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