結果
問題 | No.515 典型LCP |
ユーザー | tansunogon |
提出日時 | 2017-05-05 23:01:27 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 815 bytes |
コンパイル時間 | 696 ms |
コンパイル使用メモリ | 70,828 KB |
実行使用メモリ | 11,568 KB |
最終ジャッジ日時 | 2023-10-12 10:07:40 |
合計ジャッジ時間 | 3,610 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | TLE | - |
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 | -- | - |
ソースコード
#include <iostream> using namespace std; struct iostream_init_struct { iostream_init_struct() { std::cin.tie(0); std::cin.sync_with_stdio(false); } } iostream_init; #include <string> #include <vector> #include <algorithm> int N; string s[100000]; int M, x, d, i, j; void next() { i = (x / (N - 1)); j = (x % (N - 1)); if (i > j) { int temp = i; i = j; j = temp; } else { j = j + 1; } x = (x + d) % (N * (N - 1)); } int LCP() { int ret = 0; while (ret < min(s[i].size(), s[j].size())) { if (s[i][ret] == s[j][ret]) { ++ret; } else { break; } } return ret; } int main() { cin >> N; for (int i = 0; i < N; ++i) { cin >> s[i]; } cin >> M >> x >> d; int sum = 0; for (int indx = 0; indx < M; ++indx) { next(); sum += LCP(); } cout << sum << endl; }