Submission #29886636
Source Code Expand
/*
他决定要“格”院子里的竹子。于是他搬了一条凳子坐在院子里,面对着竹子硬想了七天,结果因为头痛而宣告失败。
DONT NEVER AROUND . //
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD=998244353;
LL n,pw[1000005];
char s[1000005];
LL QuickPow(LL x,LL p)
{
if(p<0) p+=MOD-1;
LL ans=1,base=x;
while(p)
{
if(p&1) ans=ans*base%MOD;
base=base*base%MOD;
p>>=1;
}
return ans;
}
void Solve()
{
scanf("%lld",&n);
scanf("%s",s+1);
LL ans=0;
LL mid=(n+1)/2;
for(LL i=1;i<=mid;++i) ans=(ans+pw[mid-i]*(s[i]-'A')%MOD)%MOD;
for(LL i=mid;i;--i)
{
if(s[i]<s[n-i+1])
{
ans=(ans+1)%MOD;
goto fail;
}
if(s[i]>s[n-i+1]) goto fail;
}
ans=(ans+1)%MOD;
fail:;
printf("%lld\n",ans);
}
int main(){
pw[0]=1;
for(LL i=1;i<=1000000;++i) pw[i]=pw[i-1]*26%MOD;
LL T;
scanf("%lld",&T);
while(T-->0) Solve();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - (∀x∀) |
| User | FreshP_0325 |
| Language | C++ (GCC 9.2.1) |
| Score | 500 |
| Code Size | 961 Byte |
| Status | AC |
| Exec Time | 71 ms |
| Memory | 12432 KiB |
Compile Error
./Main.cpp: In function ‘void Solve()’:
./Main.cpp:25:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
25 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
./Main.cpp:26:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
26 | scanf("%s",s+1);
| ~~~~~^~~~~~~~~~
./Main.cpp: In function ‘int main()’:
./Main.cpp:47:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
47 | scanf("%lld",&T);
| ~~~~~^~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt |
| All | hack_01.txt, sample_01.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| hack_01.txt | AC | 13 ms | 11464 KiB |
| sample_01.txt | AC | 15 ms | 11392 KiB |
| test_01.txt | AC | 61 ms | 11456 KiB |
| test_02.txt | AC | 61 ms | 11524 KiB |
| test_03.txt | AC | 67 ms | 11468 KiB |
| test_04.txt | AC | 71 ms | 11528 KiB |
| test_05.txt | AC | 67 ms | 11388 KiB |
| test_06.txt | AC | 42 ms | 11472 KiB |
| test_07.txt | AC | 26 ms | 11352 KiB |
| test_08.txt | AC | 22 ms | 11472 KiB |
| test_09.txt | AC | 17 ms | 11488 KiB |
| test_10.txt | AC | 18 ms | 11536 KiB |
| test_11.txt | AC | 18 ms | 11700 KiB |
| test_12.txt | AC | 17 ms | 11692 KiB |
| test_13.txt | AC | 16 ms | 11956 KiB |
| test_14.txt | AC | 21 ms | 11876 KiB |
| test_15.txt | AC | 19 ms | 11920 KiB |
| test_16.txt | AC | 16 ms | 12268 KiB |
| test_17.txt | AC | 19 ms | 12424 KiB |
| test_18.txt | AC | 20 ms | 12304 KiB |
| test_19.txt | AC | 18 ms | 12304 KiB |
| test_20.txt | AC | 17 ms | 12432 KiB |