Submission #38453588
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int t;
long long n, k;;
char x[200005];
int main() {
scanf("%d", &t);
for (int tt = 1; tt <= t; tt++) {
scanf("%lld%lld%s", &n, &k, x);
bool ok = 1;
for (int i = 0; i < min(n * 2, n + k); i++) {
char ta = i < n ? x[i] : x[n - 1 - (i - n)];
int tmp = (n + k - 1 - i) % (n * 2);
char tb = tmp < n ? x[tmp] : x[n - 1 - (tmp - n)];
if (ta != tb) {
ok = 0;
break;
}
}
puts(ok ? "Yes" : "No");
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - ST and TS Palindrome |
| User | nhho |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 502 Byte |
| Status | AC |
| Exec Time | 11 ms |
| Memory | 3780 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:10:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
10 | scanf("%d", &t);
| ~~~~~^~~~~~~~~~
./Main.cpp:12:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
12 | scanf("%lld%lld%s", &n, &k, x);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_01.txt, 00_sample_02.txt, 01_rand_01.txt, 01_rand_02.txt, 01_rand_03.txt, 01_rand_04.txt, 01_rand_05.txt, 01_rand_06.txt, 01_rand_07.txt, 01_rand_08.txt, 02_max_rand_01.txt, 02_max_rand_02.txt, 02_max_rand_03.txt, 02_max_rand_04.txt, 03_bit_all_01.txt, 03_bit_all_02.txt, 03_bit_all_03.txt, 03_bit_all_04.txt, 03_bit_all_05.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_01.txt | AC | 6 ms | 3460 KiB |
| 00_sample_02.txt | AC | 2 ms | 3540 KiB |
| 01_rand_01.txt | AC | 7 ms | 3588 KiB |
| 01_rand_02.txt | AC | 3 ms | 3576 KiB |
| 01_rand_03.txt | AC | 8 ms | 3540 KiB |
| 01_rand_04.txt | AC | 9 ms | 3456 KiB |
| 01_rand_05.txt | AC | 6 ms | 3432 KiB |
| 01_rand_06.txt | AC | 7 ms | 3588 KiB |
| 01_rand_07.txt | AC | 11 ms | 3624 KiB |
| 01_rand_08.txt | AC | 4 ms | 3624 KiB |
| 02_max_rand_01.txt | AC | 11 ms | 3748 KiB |
| 02_max_rand_02.txt | AC | 3 ms | 3776 KiB |
| 02_max_rand_03.txt | AC | 11 ms | 3780 KiB |
| 02_max_rand_04.txt | AC | 3 ms | 3780 KiB |
| 03_bit_all_01.txt | AC | 2 ms | 3608 KiB |
| 03_bit_all_02.txt | AC | 2 ms | 3588 KiB |
| 03_bit_all_03.txt | AC | 2 ms | 3588 KiB |
| 03_bit_all_04.txt | AC | 5 ms | 3536 KiB |
| 03_bit_all_05.txt | AC | 8 ms | 3568 KiB |