結果

問題 No.515 典型LCP
ユーザー umaumaxumaumax
提出日時 2017-05-06 00:29:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 829 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 53,760 KB
実行使用メモリ 60,568 KB
最終ジャッジ日時 2023-10-12 10:47:28
合計ジャッジ時間 3,403 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

int main(int argc, const char* argv[])
{
	uint64_t N;
	cin >> N;
	string S[N];
	for (auto&& c : S) cin >> c;
	int M, x, d;
	cin >> M >> x >> d;
	uint64_t i[M + 1];
	uint64_t j[M + 1];
	for (int k = 1; k <= M; k++) {
		//			cout << "x=" << x << endl;
		i[k] = (x / (N - 1)) + 1;
		j[k] = (x % (N - 1)) + 1;
		if (i[k] > j[k])
			swap(i[k], j[k]);
		else
			j[k] = j[k] + 1;

		x = (x + d) % (N * (N - 1));
	}
	int sum = 0;
	for (int k = 1; k <= M; k++) {
		int ik  = i[k] - 1;
		int jk  = j[k] - 1;
		int cnt = 0;
		for (int i = 0; i < S[ik].size() && i < S[jk].size(); i++) {
			if (S[ik][i] == S[jk][i])
				cnt++;
			else
				break;
		}
		//			cout << "i = " << ik << ", j = " << jk << endl;
		//			cout << "cnt = " << cnt << endl;
		sum += cnt;
	}
	cout << sum << endl;
	return 0;
}
0