結果

問題 No.1909 Detect from Substrings
ユーザー icchiposticchipost
提出日時 2022-04-23 09:12:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 712 bytes
コンパイル時間 1,603 ms
コンパイル使用メモリ 169,056 KB
実行使用メモリ 5,824 KB
最終ジャッジ日時 2023-09-07 01:18:13
合計ジャッジ時間 6,340 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 14 ms
4,380 KB
testcase_06 AC 28 ms
5,280 KB
testcase_07 AC 27 ms
5,300 KB
testcase_08 AC 28 ms
5,592 KB
testcase_09 AC 29 ms
5,588 KB
testcase_10 AC 27 ms
4,732 KB
testcase_11 AC 27 ms
4,856 KB
testcase_12 AC 26 ms
4,588 KB
testcase_13 AC 29 ms
5,660 KB
testcase_14 AC 29 ms
5,676 KB
testcase_15 AC 30 ms
5,568 KB
testcase_16 AC 27 ms
4,472 KB
testcase_17 AC 27 ms
4,380 KB
testcase_18 AC 27 ms
5,272 KB
testcase_19 AC 28 ms
5,284 KB
testcase_20 AC 28 ms
5,464 KB
testcase_21 AC 29 ms
5,584 KB
testcase_22 AC 29 ms
5,640 KB
testcase_23 AC 28 ms
4,816 KB
testcase_24 AC 26 ms
4,780 KB
testcase_25 AC 27 ms
4,596 KB
testcase_26 AC 30 ms
5,824 KB
testcase_27 AC 29 ms
5,600 KB
testcase_28 AC 29 ms
5,648 KB
testcase_29 AC 29 ms
5,600 KB
testcase_30 AC 29 ms
5,648 KB
testcase_31 AC 29 ms
5,672 KB
testcase_32 AC 30 ms
5,716 KB
testcase_33 AC 29 ms
5,584 KB
testcase_34 AC 29 ms
5,656 KB
testcase_35 AC 29 ms
5,584 KB
testcase_36 AC 29 ms
5,676 KB
testcase_37 AC 29 ms
5,588 KB
testcase_38 AC 29 ms
5,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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].substr(0, i) + s[0][i] + s[1].substr(i);
			u = s[1].substr(0, i) + s[1][i] + s[0].substr(i);
			break;
		}
	}

	int ok1 = 1, ok2 = 1;
	rep(i, n) {
		int si = 0, ti = 0;
		while (ti < m + 1) {
			if (s[i][si] == t[ti]) si++;
			ti++;
		}
		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;
}
0