結果
問題 | No.515 典型LCP |
ユーザー | T1610 |
提出日時 | 2017-05-05 23:38:48 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,118 bytes |
コンパイル時間 | 1,678 ms |
コンパイル使用メモリ | 174,592 KB |
実行使用メモリ | 118,036 KB |
最終ジャッジ日時 | 2023-10-12 10:26:46 |
合計ジャッジ時間 | 6,293 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
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 <bits/stdc++.h> using namespace std; #define rep(i,n) REP(i,0,n) #define REP(i,s,e) for(int i=(s); i<(int)(e); i++) #define pb push_back #define all(r) r.begin(),r.end() #define rall(r) r.rbegin(),r.rend() #define fi first #define se second typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll MOD = 1e9 + 7; double EPS = 1e-8; int main(){ int n; cin >> n; vector<string> s(n); rep(i, n) cin >> s[i]; //rep(i, n) cout << s[i] << endl; ll ans = 0LL; map<pii, int> mp; int m; ll x, d; cin >> m >> x >> d; rep(k, m) { int i = (x / (n-1)) + 1; int j = (x % (n-1)) + 1; if(i > j) swap(i, j); else j++; x = (x+d) % ((ll)n*(n-1LL)); i--; j--; if(mp.count({i, j})) ans += mp[{i, j}]; else { int len = min(s[i].size(), s[j].size()); int tmp = len; rep(idx, len) { if(s[i][idx] != s[j][idx]) { tmp = idx; break; } } ans += tmp; mp[{i, j}] = tmp; } //cout << " " << i << " " << j << " " << mp[{i, j}] << endl; } cout << ans << endl; }