結果

問題 No.515 典型LCP
ユーザー olpheolphe
提出日時 2017-05-05 22:50:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 991 bytes
コンパイル時間 886 ms
コンパイル使用メモリ 109,268 KB
実行使用メモリ 36,944 KB
最終ジャッジ日時 2023-10-12 10:00:19
合計ジャッジ時間 7,813 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 TLE -
testcase_03 AC 4 ms
9,476 KB
testcase_04 AC 4 ms
9,544 KB
testcase_05 AC 53 ms
30,892 KB
testcase_06 AC 55 ms
30,824 KB
testcase_07 AC 54 ms
30,904 KB
testcase_08 AC 55 ms
30,824 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int i[3000000];
int j[3000000];

int N;
string s[100001];
int M, x, d;
long long int ans;

int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	for (int i = 1; i <= N; i++)cin >> s[i];
	cin >> M >> x >> d;
	for (int k = 0; k < M; k++) {
		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));
	//	cout << i[k] << " " << j[k] << endl;
	}
	for (int k = 0; k < M; k++) {
		for (int l = 0; l < min(s[i[k]].size(), s[j[k]].size());l++) {
			if (s[i[k]][l] != s[j[k]][l]) {
				ans += l;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}
0