結果
問題 | No.1909 Detect from Substrings |
ユーザー | Rubikun |
提出日時 | 2022-04-22 21:19:50 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 2,378 bytes |
コンパイル時間 | 2,738 ms |
コンパイル使用メモリ | 211,000 KB |
実行使用メモリ | 7,108 KB |
最終ジャッジ日時 | 2023-09-06 07:35:46 |
合計ジャッジ時間 | 5,453 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 5 ms
4,380 KB |
testcase_06 | AC | 7 ms
4,456 KB |
testcase_07 | AC | 8 ms
4,508 KB |
testcase_08 | AC | 5 ms
5,260 KB |
testcase_09 | AC | 5 ms
5,100 KB |
testcase_10 | AC | 7 ms
4,624 KB |
testcase_11 | AC | 4 ms
4,748 KB |
testcase_12 | AC | 8 ms
4,544 KB |
testcase_13 | AC | 10 ms
6,016 KB |
testcase_14 | AC | 10 ms
5,664 KB |
testcase_15 | AC | 11 ms
5,816 KB |
testcase_16 | AC | 8 ms
4,552 KB |
testcase_17 | AC | 8 ms
4,384 KB |
testcase_18 | AC | 8 ms
4,376 KB |
testcase_19 | AC | 7 ms
4,524 KB |
testcase_20 | AC | 8 ms
4,560 KB |
testcase_21 | AC | 10 ms
5,504 KB |
testcase_22 | AC | 10 ms
5,256 KB |
testcase_23 | AC | 9 ms
4,792 KB |
testcase_24 | AC | 9 ms
4,712 KB |
testcase_25 | AC | 8 ms
4,608 KB |
testcase_26 | AC | 10 ms
5,760 KB |
testcase_27 | AC | 10 ms
5,648 KB |
testcase_28 | AC | 10 ms
5,484 KB |
testcase_29 | AC | 15 ms
5,676 KB |
testcase_30 | AC | 15 ms
7,108 KB |
testcase_31 | AC | 15 ms
5,936 KB |
testcase_32 | AC | 16 ms
7,060 KB |
testcase_33 | AC | 15 ms
6,088 KB |
testcase_34 | AC | 15 ms
7,084 KB |
testcase_35 | AC | 15 ms
5,792 KB |
testcase_36 | AC | 15 ms
7,108 KB |
testcase_37 | AC | 15 ms
5,784 KB |
testcase_38 | AC | 16 ms
7,056 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=998244353,MAX=300005,INF=1<<30; int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); int N,M;cin>>N>>M; vector<string> S(N); for(int i=0;i<N;i++) cin>>S[i]; string A=S[0],B=S[1]; int i=0; while(i<M&&A[i]==B[i]) i++; int j=M-1; while(j>=0&&A[j]==B[j]) j--; set<string> SE; if(i==j){ string C=A.substr(0,i)+A[i]+B[i]+A.substr(i),D=A.substr(0,i)+B[i]+A[i]+A.substr(i); { bool f=true; for(int i=0;i<N;i++){ int k=0; for(char c:C){ if(k<si(S[i])&&S[i][k]==c) k++; } if(k<si(S[i])) f=false; } if(f) SE.insert(C); } { bool f=true; for(int i=0;i<N;i++){ int k=0; for(char c:D){ if(k<si(S[i])&&S[i][k]==c) k++; } if(k<si(S[i])) f=false; } if(f) SE.insert(D); } }else{ A=A.substr(i,j-i+1); B=B.substr(i,j-i+1); if(A.substr(1)==B.substr(0,si(B)-1)){ string C=S[0].substr(0,i)+A+B.back()+S[0].substr(j+1); bool f=true; for(int i=0;i<N;i++){ int k=0; for(char c:C){ if(k<si(S[i])&&S[i][k]==c) k++; } if(k<si(S[i])) f=false; } if(f) SE.insert(C); } if(B.substr(1)==A.substr(0,si(A)-1)){ string D=S[0].substr(0,i)+B+A.back()+S[0].substr(j+1); bool f=true; for(int i=0;i<N;i++){ int k=0; for(char c:D){ if(k<si(S[i])&&S[i][k]==c) k++; } if(k<si(S[i])) f=false; } if(f) SE.insert(D); } } cout<<si(SE)<<endl; }