結果

問題 No.1909 Detect from Substrings
ユーザー icchiposticchipost
提出日時 2022-04-23 08:58:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 1,500 ms
コンパイル使用メモリ 167,996 KB
実行使用メモリ 5,712 KB
最終ジャッジ日時 2023-09-07 01:01:14
合計ジャッジ時間 5,297 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 15 ms
4,380 KB
testcase_06 AC 28 ms
5,380 KB
testcase_07 AC 28 ms
5,240 KB
testcase_08 AC 28 ms
5,304 KB
testcase_09 AC 28 ms
5,508 KB
testcase_10 AC 27 ms
4,404 KB
testcase_11 AC 27 ms
4,580 KB
testcase_12 AC 27 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

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][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;
}
0