結果

問題 No.515 典型LCP
ユーザー YukiDarumaYukiDaruma
提出日時 2017-05-05 23:21:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,082 bytes
コンパイル時間 1,671 ms
コンパイル使用メモリ 165,572 KB
実行使用メモリ 9,664 KB
最終ジャッジ日時 2023-10-12 10:17:48
合計ジャッジ時間 5,183 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 4 ms
7,424 KB
testcase_04 AC 4 ms
7,624 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 20 ms
8,280 KB
testcase_15 RE -
testcase_16 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

namespace
{
const int MAX_N = 100000;
long long i[ MAX_N + 5 ];
long long j[ MAX_N + 5 ];
long long N;
long long M;
string S[ MAX_N + 5 ];

void SetArr( const int x0, const int d0 )
{
int k;
long long x;
long long d;

	x = x0;
	d = d0;
	for( k = 1; 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 ] += 1;

		x = ( x + d ) % ( N * ( N - 1 ) );
	}
}


int Check( const string &lpA, const string &lpB )
//int Check( const char *lpA, const char *lpB )
{
int i;

	i = 0;
	while( lpA[ i ] != '\0' && lpA[ i ] == lpB[ i ] )
		i++;

	return i;
}

}		// namespace

int main( int argc, char *argv[] )
{
int a;
int x;
int d;
long long iSum;

	cin >> N;
	for( a = 1; a <= N; a++ ) cin >> S[ a ];

	cin >> M;
	cin >> x;
	cin >> d;
	SetArr( x, d );

	iSum = 0;
	for( a = 1; a <= M; a++ )
	{
		iSum += Check( S[ i[ a ] ], S[ j[ a ] ] );
//		iSum += Check( S[ i[ a ] ].c_str(), S[ j[ a ] ].c_str() );
	}

	cout << iSum << endl;

	return 0;
}




0