結果

問題 No.2761 Substitute and Search
ユーザー ttkkggwwttkkggww
提出日時 2024-05-31 11:36:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,253 bytes
コンパイル時間 4,458 ms
コンパイル使用メモリ 272,556 KB
実行使用メモリ 19,456 KB
最終ジャッジ日時 2024-05-31 11:37:12
合計ジャッジ時間 14,820 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 TLE -
testcase_05 AC 81 ms
6,940 KB
testcase_06 AC 27 ms
7,040 KB
testcase_07 AC 302 ms
13,184 KB
testcase_08 AC 45 ms
6,940 KB
testcase_09 AC 2,072 ms
13,184 KB
testcase_10 AC 30 ms
7,040 KB
testcase_11 AC 296 ms
13,184 KB
testcase_12 AC 193 ms
10,112 KB
testcase_13 AC 165 ms
10,240 KB
testcase_14 AC 1,056 ms
10,112 KB
testcase_15 AC 169 ms
9,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;

int N,L,Q;
vector<string> S;
vector<int> OP;
vector<string> T;
vector<int> K;
vector<char> C,D;

void solve(){
    sort(S.begin(),S.end());
    for(int i= 0;i<Q;i++){
        if(OP[i] == 1){
            for(int j = 0;j<N;j++){
                if(S[j][K[i]-1] == C[i]){
                    S[j][K[i]-1] = D[i];
                }
            }
            
        }else{
            sort(S.begin(),S.end());
            string l = T[i];
            string r = T[i];
            while(l.size() < L){
                l.push_back('a');
            }
            while(r.size() < L){
                r.push_back('z');
            }
            int cnt = upper_bound(S.begin(),S.end(),r) - lower_bound(S.begin(),S.end(),l);
            cout<<cnt<<endl;
        }
    }
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> N >> L >> Q;
	S.resize(N);
	OP.resize(Q);
	T.resize(Q);
	K.resize(Q);
	C.resize(Q);
	D.resize(Q);
	for(int i = 0;i<N;i++){
		cin >> S[i];
	}
	for(int i = 0;i<Q;i++){
		cin >> OP[i];
		if(OP[i] == 2){
			cin >> T[i];
		}else{
			cin >> K[i] >> C[i] >> D[i];
		}
	}
	solve();
}

0