結果

問題 No.515 典型LCP
ユーザー WA_TLEWA_TLE
提出日時 2017-05-05 23:28:54
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 389 ms / 1,000 ms
コード長 1,010 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 74,088 KB
実行使用メモリ 16,164 KB
最終ジャッジ日時 2023-10-12 10:22:28
合計ジャッジ時間 7,083 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 330 ms
16,124 KB
testcase_01 AC 365 ms
16,164 KB
testcase_02 AC 334 ms
10,372 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 327 ms
10,340 KB
testcase_06 AC 378 ms
10,552 KB
testcase_07 AC 309 ms
10,372 KB
testcase_08 AC 384 ms
10,424 KB
testcase_09 AC 308 ms
11,208 KB
testcase_10 AC 239 ms
11,192 KB
testcase_11 AC 247 ms
11,132 KB
testcase_12 AC 242 ms
11,384 KB
testcase_13 AC 375 ms
10,328 KB
testcase_14 AC 26 ms
10,424 KB
testcase_15 AC 311 ms
10,068 KB
testcase_16 AC 389 ms
10,120 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=91254389315231;//そすー
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));bmax=min(rolh[qx].size(),rolh[qx].size());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