結果

問題 No.515 典型LCP
ユーザー finefine
提出日時 2017-05-06 01:30:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 663 bytes
コンパイル時間 1,513 ms
コンパイル使用メモリ 169,152 KB
実行使用メモリ 10,504 KB
最終ジャッジ日時 2023-10-12 11:12:34
合計ジャッジ時間 9,145 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
10,504 KB
testcase_01 AC 177 ms
6,084 KB
testcase_02 TLE -
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 73 ms
4,352 KB
testcase_06 AC 75 ms
4,348 KB
testcase_07 AC 74 ms
4,348 KB
testcase_08 AC 78 ms
4,352 KB
testcase_09 AC 978 ms
4,352 KB
testcase_10 AC 372 ms
4,348 KB
testcase_11 AC 465 ms
4,348 KB
testcase_12 AC 466 ms
4,352 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m, x, d;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) cin >> s[i];
	cin >> m >> x >> d;
	map<P, int> memo;
	long long ans = 0;
	for (int k = 0; k < m; k++) {
		int i = x / (n - 1);
		int j = x % (n - 1);
		if (i > j) swap(j, i);
		else j++;
		int lmin = min(s[i].length(), s[j].length());
		int tmp = lmin;
		for (int h = 0; h < lmin; h++) {
			if (s[i][h] != s[j][h]) {
				tmp = h;
				break;
			}
		}
		ans += tmp;
		x = (x + d) % (n * (n - 1));
	}
	cout << ans << endl;
	return 0;
}
0