結果
| 問題 | No.1909 Detect from Substrings |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-23 08:58:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 652 bytes |
| コンパイル時間 | 1,718 ms |
| コンパイル使用メモリ | 170,480 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-24 19:38:12 |
| 合計ジャッジ時間 | 5,012 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 26 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using pii = pair<int, int>;
using ll = long long;
int main() {
int n, m;
cin >> n >> m;
vector<string> s(n);
rep(i, n) cin >> s[i];
string t, u;
rep(i, m) {
if (s[0][i] != s[1][i]) {
t = s[0][i] + s[1].substr(i);
u = s[1][i] + s[0].substr(i);
break;
}
}
int ok1 = 1, ok2 = 1;
rep(i, n) {
int si = 0;
rep(ti, m + 1) {
if (s[i][si] == t[ti]) si++;
}
if (si != m) ok1 = 0;
si = 0;
rep(ui, m + 1) {
if (s[i][si] == u[ui]) si++;
}
if (si != m) ok2 = 0;
}
int ans = ok1 + ok2;
cout << ans << endl;
return 0;
}