結果
問題 |
No.515 典型LCP
|
ユーザー |
![]() |
提出日時 | 2017-05-05 22:34:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,255 bytes |
コンパイル時間 | 1,243 ms |
コンパイル使用メモリ | 114,344 KB |
実行使用メモリ | 168,000 KB |
最終ジャッジ日時 | 2024-09-14 09:52:59 |
合計ジャッジ時間 | 9,192 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 TLE * 3 |
ソースコード
#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; }