結果
| 問題 | 
                            No.515 典型LCP
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2017-05-05 22:53:23 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,010 bytes | 
| コンパイル時間 | 1,045 ms | 
| コンパイル使用メモリ | 109,196 KB | 
| 実行使用メモリ | 36,096 KB | 
| 最終ジャッジ日時 | 2024-09-14 08:56:09 | 
| 合計ジャッジ時間 | 4,073 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | -- * 2 | 
| other | AC * 1 WA * 1 TLE * 1 -- * 12 | 
ソースコード
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"
using namespace std;
const long long int MOD = 1000000007;
int i[3000000];
int j[3000000];
long long int N;
string s[100001];
int si[100001];
long long int M, x, d;
long long int ans;
int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> s[i];
		si[i] = (int)s[i].size();
	}
	cin >> M >> x >> d;
	for (int k = 0; k < M; k++) {
		i[k] = (x / (N - 1)) + 1;
		j[k] = (x % (N - 1)) + 1;
		if (i[k] > j[k]) {
			swap(i[k], j[k]);
		}
		else {
			j[k] = j[k] + 1;
		}
		x = (x + d) % (N * (N - 1));
	}
	for (int k = 0; k < M; k++) {
		for (int l = 0; l < min(si[i[k]], si[j[k]]);l++) {
			if (s[i[k]][l] != s[j[k]][l]) {
				ans += l;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}