Submission #17682373
Source Code Expand
#include<bits/stdc++.h>
typedef int LL;
typedef double dl;
#define opt operator
#define pb push_back
const LL maxn=7e3+9,mod=998244353,inf=0x3f3f3f3f;
LL Read(){
LL x(0),f(1); char c=getchar();
while(c<'0' || c>'9'){
if(c=='-') f=-1; c=getchar();
}
while(c>='0' && c<='9'){
x=(x<<3ll)+(x<<1ll)+c-'0'; c=getchar();
}return x*f;
}
void Chkmin(LL &x,LL y){
if(y<x) x=y;
}
void Chkmax(LL &x,LL y){
if(y>x) x=y;
}
LL add(LL x,LL y){
return x+=y,x>=mod?x-mod:x;
}
LL dec(LL x,LL y){
return x-=y,x<0?x+mod:x;
}
LL mul(LL x,LL y){
return 1ll*x*y%mod;
}
LL Pow(LL base,LL b){
LL ret(1); while(b){
if(b&1) ret=mul(ret,base); base=mul(base,base); b>>=1;
}return ret;
}
LL n,ans;
LL B[maxn][maxn],vis[maxn],a[maxn],fc2[maxn],b[maxn];
char s[maxn][maxn];
void Insert(LL *A,LL len){
for(LL i=len;i>=1;--i)if(A[i]){
if(!vis[i]){
for(LL j=1;j<=i;++j) B[i][j]=A[j]; vis[i]=1;
return;
}else{
for(LL j=1;j<=i;++j) A[j]^=B[i][j];
}
}
}
void Solve(){
LL cnt(0);
for(LL i=strlen(s[0]+1);i>=1;--i) cnt+=vis[i];
if(!vis[strlen(s[0]+1)]){
printf("%d\n",fc2[cnt]); return;
}
static LL C[maxn];
/*
for(LL i=strlen(s[0]+1);i>=1;--i){
for(LL j=1;j<=i;++j) printf("%d",B[i][j]); puts("");
}
*/
//printf("# %d\n",cnt);
//for(LL i=strlen(s[0]+1);i>=1;--i) printf("%d",a[i]); puts("");
for(LL i=strlen(s[0]+1);i>=1;--i)
if(vis[i]){
--cnt;
if(a[i]){
if(C[i]){
ans=add(ans,fc2[cnt]);
}else{
//puts("033");
ans=add(ans,fc2[cnt]);
for(LL j=1;j<=i;++j) C[j]^=B[i][j];
}
}else{
if(C[i]){
for(LL j=1;j<=i;++j) C[j]^=B[i][j];
}
}
//printf("(%d,%d)\n",i,ans);
}else{
if(!a[i] && C[i]){
printf("%d\n",ans);
return;
}
if(a[i] && !C[i]){
ans=add(ans,fc2[cnt]); printf("%d\n",ans);
return;
}
}
ans=add(ans,1);
printf("%d\n",ans);
}
int main(){
n=Read(); scanf(" %s",s[0]+1);
for(LL i=1,len=strlen(s[0]+1);i<=len;++i) a[i]=s[0][i]-'0';
for(LL i=1,len=strlen(s[0]+1);i<=len/2;++i) std::swap(a[i],a[len-i+1]);
//for(LL i=strlen(s[0]+1);i>=1;--i) printf("%d",a[i]); puts("");
LL mx=(strlen(s[0]+1));
fc2[0]=1; for(LL i=1;i<=mx;++i) fc2[i]=mul(fc2[i-1],2);
mx+=3000;
for(LL i=1;i<=n;++i){
scanf(" %s",s[i]+1);
Chkmax(mx,strlen(s[i]+1));
LL len(strlen(s[i]+1));
for(LL j=1;j<=(len/2);++j) std::swap(s[i][j],s[i][len-j+1]);
}
//for(LL i=1;i<=n;++i) printf("%s\n",s[i]+1);
//printf("%d\n",mx);
for(LL i=1;i<=n;++i){
LL len(strlen(s[i]+1));
for(LL j=1;j<=len;++j) b[j]=s[i][j]-'0';
while(len<=mx){
Insert(b,len);
++len;
for(LL j=len;j>=1;--j) b[j]=b[j-1];
}
}
Solve();
return 0;
}
Submission Info
Submission Time
2020-10-27 12:07:24+0900
Task
F - XorShift
User
Grice
Language
C++ (GCC 9.2.1)
Score
1000
Code Size
2772 Byte
Status
AC
Exec Time
183 ms
Memory
125656 KiB
Compile Error
./Main.cpp: In function ‘LL Read()’:
./Main.cpp:10:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
10 | if(c=='-') f=-1; c=getchar();
| ^~
./Main.cpp:10:20: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
10 | if(c=='-') f=-1; c=getchar();
| ^
./Main.cpp: In function ‘LL Pow(LL, LL)’:
./Main.cpp:33:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
33 | if(b&1) ret=mul(ret,base); base=mul(base,base); b>>=1;
| ^~
./Main.cpp:33:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
33 | if(b&1) ret=mul(ret,base); base=mul(base,base); b>>=1;
| ^~~~
./Main.cpp: In function ‘void Insert(LL*, LL)’:
./Main.cpp:42:4: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
42 | for(LL j=1;j<=i;++j) B[i][j]=A[j]; vis[i]=1;
| ^~~
./Main.cpp:42:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
42 | for(LL j=1;j<=i;++j) B[i][j]=A[j]; vis[i]=1;
| ^~~
./Main.cpp: In function ‘int main()’:
./Main.cpp:94:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
94 | n=Read(); scanf(" %s",s[0]+1);
| ~~~~~^~~~~~~~~~~~~~
./Main.cpp:102:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
102 | scanf(" %s",s[i]+1);
| ~~~~~^~~~~~~~~~~~~~
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
1000 / 1000
Status
Set Name
Test Cases
Sample
s1.txt, s2.txt, s3.txt, s4.txt
All
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, s1.txt, s2.txt, s3.txt, s4.txt
Case Name
Status
Exec Time
Memory
01.txt
AC
183 ms
125596 KiB
02.txt
AC
164 ms
125492 KiB
03.txt
AC
177 ms
125476 KiB
04.txt
AC
167 ms
124252 KiB
05.txt
AC
164 ms
125484 KiB
06.txt
AC
163 ms
125408 KiB
07.txt
AC
171 ms
118032 KiB
08.txt
AC
167 ms
125556 KiB
09.txt
AC
163 ms
125572 KiB
10.txt
AC
169 ms
115516 KiB
11.txt
AC
165 ms
125488 KiB
12.txt
AC
167 ms
118228 KiB
13.txt
AC
161 ms
125276 KiB
14.txt
AC
163 ms
125448 KiB
15.txt
AC
181 ms
125340 KiB
16.txt
AC
134 ms
93472 KiB
17.txt
AC
165 ms
124712 KiB
18.txt
AC
163 ms
124048 KiB
19.txt
AC
162 ms
122836 KiB
20.txt
AC
170 ms
119840 KiB
21.txt
AC
156 ms
117552 KiB
22.txt
AC
151 ms
111676 KiB
23.txt
AC
141 ms
96220 KiB
24.txt
AC
153 ms
109780 KiB
25.txt
AC
150 ms
109852 KiB
26.txt
AC
149 ms
109056 KiB
27.txt
AC
143 ms
99252 KiB
28.txt
AC
131 ms
88996 KiB
29.txt
AC
125 ms
82128 KiB
30.txt
AC
122 ms
78552 KiB
31.txt
AC
164 ms
125312 KiB
32.txt
AC
140 ms
91300 KiB
33.txt
AC
163 ms
125656 KiB
34.txt
AC
162 ms
125360 KiB
35.txt
AC
129 ms
83032 KiB
36.txt
AC
176 ms
121256 KiB
37.txt
AC
164 ms
124860 KiB
38.txt
AC
153 ms
102784 KiB
39.txt
AC
163 ms
122664 KiB
40.txt
AC
162 ms
119796 KiB
41.txt
AC
169 ms
117616 KiB
42.txt
AC
156 ms
106112 KiB
43.txt
AC
152 ms
110192 KiB
44.txt
AC
150 ms
109592 KiB
45.txt
AC
129 ms
83304 KiB
46.txt
AC
159 ms
109096 KiB
47.txt
AC
132 ms
86312 KiB
48.txt
AC
133 ms
89032 KiB
49.txt
AC
130 ms
82268 KiB
50.txt
AC
125 ms
78216 KiB
51.txt
AC
119 ms
78132 KiB
52.txt
AC
123 ms
78224 KiB
53.txt
AC
125 ms
78472 KiB
54.txt
AC
145 ms
103700 KiB
55.txt
AC
158 ms
119600 KiB
56.txt
AC
161 ms
123708 KiB
s1.txt
AC
38 ms
33172 KiB
s2.txt
AC
40 ms
33448 KiB
s3.txt
AC
41 ms
33572 KiB
s4.txt
AC
27 ms
34212 KiB