結果

問題 No.515 典型LCP
ユーザー WA_TLEWA_TLE
提出日時 2017-05-05 23:23:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,011 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 81,504 KB
実行使用メモリ 16,544 KB
最終ジャッジ日時 2023-10-12 10:19:48
合計ジャッジ時間 6,628 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 309 ms
16,332 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 329 ms
10,428 KB
testcase_06 AC 380 ms
10,388 KB
testcase_07 AC 314 ms
10,440 KB
testcase_08 AC 385 ms
10,480 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 315 ms
10,164 KB
testcase_16 AC 394 ms
10,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<string>
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long int llint;
#define pub push_back
#define mp make_pair
#define fir first
#define sec second
const int big=((llint)1<<30);
const llint mod=967916333;//そすー
const int lol=101;
//aabbaabb

//
int main(void){
	llint x,y,n,i,gen,bmax,bmin,q,j,m,d,k,qx,qy,ans=0;
	vector<string> a;
	vector<vector<llint>> rolh;
	cin>>n;
	a.resize(n);
	rolh.resize(n);
	for(i=0;i<n;i++){
		cin>>a[i];
		rolh[i].resize(a[i].size());gen=0;
		for(j=0;j<a[i].size();j++){
			gen*=lol;
			gen+=a[i][j];
			gen%=mod;
			rolh[i][j]=gen;
		}
	}
	cin>>m>>x>>d;
	for(k=1;k<=m;k++){
		qx=(x/(n-1));
		qy=(x%(n-1));
		if(qx>qy){swap(qx,qy);} else{qy++;}
		x=(x+d)%(n*(n-1));i=0;bmax=min(rolh[qx].size(),rolh[qx].size())-1;bmin=-1;
		while(bmax-bmin>1){
			gen=(bmax+bmin)/2;
			if(rolh[qx][gen]!=rolh[qy][gen]){ bmax=gen; } else{ bmin=gen; }
		}
		ans+=bmax;
	}
	cout<<ans<<endl;
	return 0;
}
0