結果
| 問題 | No.515 典型LCP |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-06 02:18:14 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,213 bytes |
| 記録 | |
| コンパイル時間 | 554 ms |
| コンパイル使用メモリ | 62,284 KB |
| 実行使用メモリ | 8,192 KB |
| 最終ジャッジ日時 | 2024-07-08 11:07:36 |
| 合計ジャッジ時間 | 3,789 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 1 RE * 14 |
ソースコード
#include <algorithm>
#include <bitset>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;
const int N = 100010;
string s[N];
// Greedy exhaustive search. It should fail with TLE.
int main(void){
int n;
cin >> n;
assert (n <= 100000);
int tot_len = 0;
REP(i, 0, n) {
cin >> s[i];
tot_len += s[i].length();
}
assert (tot_len <= 800000);
int m;
cin >> m;
assert (m <= 300000);
ll x, d;
cin >> x >> d;
ll lim = ll(n) * ll(n - 1);
assert (0 <= x);
assert (x < lim);
assert (d < lim);
assert (0 <= d);
REP(loop_cnt, 0, m) {
int i, j;
i = (x / (n - 1)) + 1;
j = (x % (n - 1)) + 1;
if (i > j) {
swap(i, j);
} else {
j++;
}
assert (1 <= i);
assert (i < j);
assert (j <= n);
i--, j--;
int pos = 0;
int lim = min(s[i].length(), s[j].length());
for (; pos < lim; ++pos) {
if (s[i][pos] != s[j][pos]) break;
}
cout << pos << endl;
x = (x + d) % (ll(n) * ll(n - 1));
}
}