結果
| 問題 |
No.2020 Sum of Common Prefix Length
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-17 20:50:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 659 bytes |
| コンパイル時間 | 4,871 ms |
| コンパイル使用メモリ | 252,200 KB |
| 最終ジャッジ日時 | 2025-01-28 19:00:40 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 TLE * 27 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define emb emplace_back
using ll = long long;
int main(){
cin.tie(0);ios::sync_with_stdio(false);
int N;cin >> N;
vector<string> S(N);
for(string &s:S) cin >> s;
int Q;cin >> Q;
for(int i=0;i<Q;i++){
int t;cin >> t;
if(t == 1){
int x;char c;cin >> x >> c;x--;
S[x] += c;
}
else{
int x;cin >> x;x--;
ll ans = 0;
for(int i=0;i<N;i++){
for(int j=0;j<min(S[x].size(),S[i].size());j++){
if(S[x][j] == S[i][j]) ans++;
else break;
}
}
cout << ans << "\n";
}
}
}