結果

問題 No.515 典型LCP
ユーザー sugim48sugim48
提出日時 2017-05-05 22:34:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,255 bytes
コンパイル時間 1,331 ms
コンパイル使用メモリ 111,944 KB
実行使用メモリ 167,720 KB
最終ジャッジ日時 2023-10-12 11:00:44
合計ジャッジ時間 9,225 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 TLE -
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 158 ms
4,516 KB
testcase_06 AC 163 ms
4,628 KB
testcase_07 AC 164 ms
4,560 KB
testcase_08 AC 163 ms
4,756 KB
testcase_09 AC 349 ms
17,496 KB
testcase_10 AC 158 ms
5,256 KB
testcase_11 AC 159 ms
5,108 KB
testcase_12 AC 159 ms
5,372 KB
testcase_13 AC 173 ms
4,624 KB
testcase_14 AC 20 ms
5,068 KB
testcase_15 AC 150 ms
4,352 KB
testcase_16 AC 153 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

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>
#include <unordered_map>
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;
	unordered_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