結果
| 問題 | 
                            No.958 たぷりすたべる (回文)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-01-21 11:57:05 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 930 bytes | 
| コンパイル時間 | 744 ms | 
| コンパイル使用メモリ | 76,248 KB | 
| 実行使用メモリ | 500,396 KB | 
| 最終ジャッジ日時 | 2024-07-05 05:58:09 | 
| 合計ジャッジ時間 | 9,291 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 35 TLE * 1 -- * 17 | 
ソースコード
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#define REP(i,N) for(int i=0,__i=N;i<__i;++i)
long long N,K,Q;
std::string S;
std::vector<long long> A;
bool input(){
	using namespace std;
	cin>>N>>K>>Q;
	if(N>2*pow(10,5)||N<1||Q>2*pow(10,5)||Q<1||K>pow(10,9)||K<1)
		return false;
	string s;
	cin>>s;
	REP(i,K)
		S+=s;
	A.resize(Q);
	REP(i,Q){
		cin>>A[i];
		if(A[i]<1||A[i]>K*N)
			return false;
	}
	return true;
}
void solve(){
	using namespace std;
	int start,front,back,n;
/*
int __c=0;
cout<<"S:"<<S<<endl;
for(char c:S){
	cout<<__c++<<" "<<c<<endl;
}
*/
	REP(i,Q){
		n=A[i]-1;
//cout<<"n:"<<n<<endl;
		start=n;
		front=n;
		back=n;
		while(S[--front]==S[++back]&&front>=0);
//cout<<"front:"<<front<<" back:"<<back<<endl;
		front++;
		back--;
		if(i<0||front==n)
			cout<<1<<endl;
		else
			cout<<back-front+1<<endl;
	}
}
int main(){
	using namespace std;
	if(!input())
		return -1;
	solve();
}