結果
| 問題 |
No.2992 Range ABCD String Query
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-17 00:56:14 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 535 ms / 6,000 ms |
| コード長 | 1,344 bytes |
| コンパイル時間 | 5,983 ms |
| コンパイル使用メモリ | 313,400 KB |
| 実行使用メモリ | 48,808 KB |
| 最終ジャッジ日時 | 2024-12-17 00:56:41 |
| 合計ジャッジ時間 | 22,948 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 41 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::static_modint<998244353>;
//using mint = atcoder::static_modint<1000000007>;
using namespace std;
using namespace atcoder;
using ld = long double;
using ll = long long;
#define mp(a,b) make_pair(a,b)
#define rep(i,s,n) for(int i=s; i<n; i++)
const vector<int> dx{1,0,-1,0},dy{0,1,0,-1};
struct P{
int a[4][4];
P(){
rep(i,0,4)rep(j,0,4)a[i][j]=0;
}
};
P convert(char c){
P z;
rep(i,0,4)rep(j,i,4){
if(i<=c-'A' && c-'A'<=j)z.a[i][j]=0;
else z.a[i][j]=1;
}
return z;
}
P op(P x,P y){
P z;
rep(i,0,4)rep(j,i,4)z.a[i][j]=1e9;
rep(i,0,4)rep(j,i,4)rep(k,j,4){
z.a[i][k]=min(z.a[i][k],x.a[i][j]+y.a[j][k]);
}
return z;
}
P e(){return P();}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,Q;cin >> n >> Q;
string s;cin >> s;
segtree<P,op,e> seg(n);
rep(i,0,n)seg.set(i,convert(s[i]));
vector<int> out;
rep(q,0,Q){
int t;cin >> t;
if(t==1){
int x;cin >> x;
char c;cin >> c;
seg.set(x-1,convert(c));
continue;
}
int l,r;
cin >> l >> r;
l--;
auto p=seg.prod(l,r);
out.push_back(p.a[0][3]);
}
for(auto x:out)cout << x << "\n";
}