結果

問題 No.958 たぷりすたべる (回文)
ユーザー vectorccvectorcc
提出日時 2020-01-21 12:01:55
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 888 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 74,364 KB
実行使用メモリ 500,328 KB
最終ジャッジ日時 2024-07-05 06:04:56
合計ジャッジ時間 24,054 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other AC * 1 WA * 31 TLE * 4 -- * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'bool solve()':
main.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
   55 | }
      | ^

ソースコード

diff #

#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;
	return true;
}

bool 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){
		cin>>n;
		if(n<1||n>K*N)
			return false;
		n--;
//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();
}
0