結果

問題 No.515 典型LCP
ユーザー sugim48sugim48
提出日時 2017-05-05 22:31:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,220 bytes
コンパイル時間 929 ms
コンパイル使用メモリ 107,152 KB
実行使用メモリ 205,244 KB
最終ジャッジ日時 2023-10-12 09:56:40
合計ジャッジ時間 5,599 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
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 #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

int const MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-12;
int INF = INT_MAX / 2;

int main() {
	int N; cin >> N;
	vector<string> s(N);
	rep(i, N) cin >> s[i];
	int M; ll x, d;
	cin >> M >> x >> d;
	map<ll, int> mp;
	ll ans = 0;
	while (M--) {
		int i = x / (N - 1), j = x % (N - 1);
		if (i > j) swap(i, j);
		else j++;
		if (!mp.count(x)) {
			int k;
			for (k = 0; k < s[i].length() && k < s[j].length() && s[i][k] == s[j][k]; k++);
			mp[x] = k;
		}
		ans += mp[x];
		x = (x + d) % (N * (N - 1));
	}
	cout << ans << endl;
}
0