結果
| 問題 |
No.515 典型LCP
|
| コンテスト | |
| ユーザー |
sugim48
|
| 提出日時 | 2017-05-05 22:31:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,220 bytes |
| コンパイル時間 | 1,174 ms |
| コンパイル使用メモリ | 107,588 KB |
| 実行使用メモリ | 204,544 KB |
| 最終ジャッジ日時 | 2024-09-14 08:50:46 |
| 合計ジャッジ時間 | 5,855 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | TLE * 1 -- * 14 |
ソースコード
#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;
}
sugim48