結果
| 問題 |
No.2554 MMA文字列2 (Query Version)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-09 17:15:06 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,906 bytes |
| コンパイル時間 | 8,376 ms |
| コンパイル使用メモリ | 352,280 KB |
| 実行使用メモリ | 813,888 KB |
| 最終ジャッジ日時 | 2024-09-29 21:16:20 |
| 合計ジャッジ時間 | 11,564 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 MLE * 1 -- * 43 |
ソースコード
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,m,n,k) for (int i = (int)(m); i < (int)(n); i += (int)(k))
#define rrep(i,m,n,k) for (int i = (int)(m); i > (int)(n); i += (int)(k))
#define ll long long
#define list(T,A,N) vector<T> A(N);for(int i=0;i<(int)(N);i++){cin >> A[i];}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
// #define int long long
constexpr int L = 26*27+1;
constexpr int M = 26;
array<ll,L> op( array<ll,L> x,array<ll,L> y){
array<ll,L> z;
rep(i,0,L,1){
z[i] = x[i]+y[i];
}
rep(i,0,M,1){
rep(j,0,M,1){
if(i!=j){
z[L-1] = (z[L-1]
+ x[i]*y[M*(i+1)+j]
+ x[M*(i+1)+i]*y[j]);
}
z[M*(i+1)+j] = z[M*(i+1)+j] + x[i]*y[j];
}
}
return z;
}
array<ll,L> e(){
array<ll,L> z;
rep(i,0,L,1){
z[i] = 0;
}
return z;
}
array<ll,L> conv(char s){
array<ll,L> z;
rep(i,0,L,1){
z[i] = 0;
}
z[s-'A'] = 1;
return z;
}
int main(){
// ios::sync_with_stdio(false);
// std::cin.tie(nullptr);
int N;
cin >> N;
string S;
cin >> S;
int Q;
cin >> Q;
vector<array<ll,L>> I;
for(auto s:S){
I.push_back(conv(s));
}
segtree<array<ll,L>,op,e> T(I);
int t,x,l,r;
char c;
rep(_,0,Q,1){
cin >> t;
if(t==1){
cin >> x >> c;
x -= 1;
T.set(x,conv(c));
}
else{
cin >> l >> r;
l -= 1;
cout << T.prod(l,r)[L-1] << "\n";
}
}
return 0;
}