結果
| 問題 |
No.958 たぷりすたべる (回文)
|
| コンテスト | |
| ユーザー |
tarattata1
|
| 提出日時 | 2019-12-21 00:33:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,506 bytes |
| コンパイル時間 | 545 ms |
| コンパイル使用メモリ | 74,596 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-18 05:16:27 |
| 合計ジャッジ時間 | 3,761 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 38 WA * 15 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:44:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
44 | scanf("%d%d%d", &N, &K, &Q);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:45:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
45 | scanf("%s", str);
| ~~~~~^~~~~~~~~~~
main.cpp:61:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
61 | scanf("%d", &p); p--;
| ~~~~~^~~~~~~~~~
ソースコード
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;
char str[200005];
void func(int N, const char* S, int* R )
{
int i = 0, j = 0;
while (i < N) {
while (i-j >= 0 && i+j < N && S[i-j] == S[i+j]) ++j;
R[i] = j;
int k = 1;
while (i-k >= 0 && i+k < N && k+R[i-k] < j) R[i+k] = R[i-k], ++k;
i += k; j -= k;
}
return;
}
int main(int argc, char* argv[])
{
int N,K,Q;
scanf("%d%d%d", &N, &K, &Q);
scanf("%s", str);
vector<char> ss;
int i,k;
for(k=0; k<3; k++) {
for(i=0; i<N; i++) {
ss.push_back(str[i]);
}
}
ss.push_back('\0');
vector<int> a(N*3);
func(3*N, &ss[0], &a[0]);
for(i=0; i<Q; i++) {
int p;
scanf("%d", &p); p--;
int q=p%N;
ll r=a[q+N]-1;
if(r>=N) {
r=MIN(p,(ll)N*K-1-p);
printf("%lld\n", 2*r+1);
}
else {
r=MIN(MIN(r,p),(ll)N*K-1-p);
printf("%lld\n", 2*r+1);
}
}
return 0;
}
tarattata1