QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#469061#4893. ImbalanceN_z_20 593ms12040kbC++145.3kb2024-07-09 12:17:272024-07-09 12:17:27

Judging History

你现在查看的是最新测评结果

  • [2024-07-09 12:17:27]
  • 评测
  • 测评结果:20
  • 用时:593ms
  • 内存:12040kb
  • [2024-07-09 12:17:27]
  • 提交

answer

#if defined(LOCAL) or not defined(LUOGU)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,unroll-loops")
#endif
#include<bits/stdc++.h>
using namespace std;
struct time_helper
{
#ifdef LOCAL
    clock_t time_last;
#endif
    time_helper()
    {
#ifdef LOCAL
        time_last=clock();
#endif
    }
    void test()
    {
#ifdef LOCAL
        auto time_now=clock();
        std::cerr<<"time:"<<1.*(time_now-time_last)/CLOCKS_PER_SEC<<";all_time:"<<1.*time_now/CLOCKS_PER_SEC<<std::endl;
        time_last=time_now;
#endif
    }
    ~time_helper()
    {
        test();
    }
}time_helper;
#ifdef LOCAL
#include"dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
namespace Fread{const int SIZE=1<<16;char buf[SIZE],*S,*T;inline char getchar(){if(S==T){T=(S=buf)+fread(buf,1,SIZE,stdin);if(S==T)return'\n';}return *S++;}}namespace Fwrite{const int SIZE=1<<16;char buf[SIZE],*S=buf,*T=buf+SIZE;inline void flush(){fwrite(buf,1,S-buf,stdout);S=buf;}inline void putchar(char c){*S++=c;if(S==T)flush();}struct NTR{~NTR(){flush();}}ztr;}
#define getchar Fread::getchar
#define putchar Fwrite::putchar
#define Setprecision 10
#define between '\n'
#define __int128 long long
template<typename T>struct is_char{static constexpr bool value=(std::is_same<T,char>::value||std::is_same<T,signed char>::value||std::is_same<T,unsigned char>::value);};template<typename T>struct is_integral_ex{static constexpr bool value=(std::is_integral<T>::value||std::is_same<T,__int128>::value)&&!is_char<T>::value;};template<typename T>struct is_floating_point_ex{static constexpr bool value=std::is_floating_point<T>::value||std::is_same<T,__float128>::value;};namespace Fastio{struct Reader{template<typename T>typename std::enable_if_t<std::is_class<T>::value,Reader&>operator>>(T&x){for(auto &y:x)*this>>y;return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1;while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}x=0;while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;return *this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1,s=0;x=0;T t=0;while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else return x*=f,*this;while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Reader&>operator>>(T&c){c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();return *this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}Reader&operator>>(std::string&str){str.clear();char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';struct Writer{typedef __int128 mxdouble;template<typename T>typename std::enable_if_t<std::is_class<T>::value,Writer&>operator<<(T x){for(auto &y:x)*this<<y<<between;*this<<'\n';return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Writer&>operator<<(T x){if(x==0)return putchar('0'),*this;if(x<0)putchar('-'),x=-x;static int sta[45];int top=0;while(x)sta[++top]=x%10,x/=10;while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Writer&>operator<<(T x){if(x<0)putchar('-'),x=-x;x+=pow(10,-Setprecision)/2;mxdouble _=x;x-=(T)_;static int sta[45];int top=0;while(_)sta[++top]=_%10,_/=10;if(!top)putchar('0');while(top)putchar(sta[top]+'0'),--top;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Writer&>operator<<(T c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return *this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}Writer&operator<<(std::string str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl

void solve();
main()
{
#if not defined(LOCAL) and not defined(ONLINE_JUDGE)
    string A="bal";freopen((A+".in").c_str(),"r",stdin);freopen((A+".out").c_str(),"w",stdout);
#endif
    int t=1;
    // cin>>t;
    while(t--)solve();
}
constexpr int p=998244353;
int dp[1<<20],ndp[1<<20];
void solve()
{
    int n,k,m;
    cin>>n>>k>>m;
    int now=0;
    for(int x=1;x<=m;x++)
    {
        char ch;
        cin>>ch;
        now=now*2+ch-'0';
    }
    int bas=(1<<k)-1;
    dp[now]=1;
    for(int x=m+1;x<=n;x++)
    {
        for(int y=0;y<(1<<k);y++)
        if(dp[y])
        for(int z:{0,1})
        {
            int nxt=(y*2+z)&bas;
            if(x>=k&&__builtin_popcount(nxt)*2==k)continue;
            ndp[nxt]=(ndp[nxt]+dp[y])%p;
        }
        for(int y=0;y<(1<<k);y++)
        dp[y]=ndp[y],ndp[y]=0;
    }
    int ans=0;
    for(int x=0;x<(1<<k);x++)
    ans=(ans+dp[x])%p;
    cout<<ans<<endl;
}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 5548kb

input:

2 2 0

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 5864kb

input:

2 2 1
0

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 5668kb

input:

3 2 0

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 1ms
memory: 5832kb

input:

3 2 1
0

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 1ms
memory: 5868kb

input:

4 2 0

output:

2

result:

ok 1 number(s): "2"

Test #6:

score: 0
Accepted
time: 0ms
memory: 5600kb

input:

4 2 1
0

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 1ms
memory: 5896kb

input:

4 4 0

output:

10

result:

ok 1 number(s): "10"

Test #8:

score: 0
Accepted
time: 1ms
memory: 5664kb

input:

4 4 1
1

output:

5

result:

ok 1 number(s): "5"

Test #9:

score: 0
Accepted
time: 1ms
memory: 5668kb

input:

4 4 2
00

output:

3

result:

ok 1 number(s): "3"

Test #10:

score: 0
Accepted
time: 0ms
memory: 5904kb

input:

4 4 3
101

output:

1

result:

ok 1 number(s): "1"

Test #11:

score: 0
Accepted
time: 0ms
memory: 5668kb

input:

5 2 0

output:

2

result:

ok 1 number(s): "2"

Test #12:

score: 0
Accepted
time: 0ms
memory: 5672kb

input:

5 2 1
1

output:

1

result:

ok 1 number(s): "1"

Test #13:

score: 0
Accepted
time: 0ms
memory: 5896kb

input:

5 4 0

output:

14

result:

ok 1 number(s): "14"

Test #14:

score: 0
Accepted
time: 0ms
memory: 5892kb

input:

5 4 1
0

output:

7

result:

ok 1 number(s): "7"

Test #15:

score: 0
Accepted
time: 0ms
memory: 5588kb

input:

5 4 2
01

output:

3

result:

ok 1 number(s): "3"

Test #16:

score: 0
Accepted
time: 1ms
memory: 5660kb

input:

5 4 3
110

output:

1

result:

ok 1 number(s): "1"

Test #17:

score: 0
Accepted
time: 0ms
memory: 5676kb

input:

17 2 0

output:

2

result:

ok 1 number(s): "2"

Test #18:

score: 0
Accepted
time: 0ms
memory: 5676kb

input:

17 2 0

output:

2

result:

ok 1 number(s): "2"

Test #19:

score: 0
Accepted
time: 1ms
memory: 5604kb

input:

17 10 6
110111

output:

621

result:

ok 1 number(s): "621"

Test #20:

score: 0
Accepted
time: 1ms
memory: 5580kb

input:

17 10 2
11

output:

8413

result:

ok 1 number(s): "8413"

Test #21:

score: 0
Accepted
time: 0ms
memory: 5600kb

input:

18 2 1
1

output:

1

result:

ok 1 number(s): "1"

Test #22:

score: 0
Accepted
time: 0ms
memory: 5572kb

input:

18 2 1
1

output:

1

result:

ok 1 number(s): "1"

Test #23:

score: 0
Accepted
time: 0ms
memory: 5636kb

input:

18 8 5
00010

output:

918

result:

ok 1 number(s): "918"

Test #24:

score: 0
Accepted
time: 1ms
memory: 5640kb

input:

18 8 3
001

output:

3404

result:

ok 1 number(s): "3404"

Test #25:

score: 0
Accepted
time: 1ms
memory: 6120kb

input:

18 16 6
100011

output:

2458

result:

ok 1 number(s): "2458"

Test #26:

score: 0
Accepted
time: 0ms
memory: 5892kb

input:

18 16 8
00101101

output:

548

result:

ok 1 number(s): "548"

Test #27:

score: 0
Accepted
time: 0ms
memory: 5668kb

input:

19 2 1
1

output:

1

result:

ok 1 number(s): "1"

Test #28:

score: 0
Accepted
time: 1ms
memory: 5832kb

input:

19 2 0

output:

2

result:

ok 1 number(s): "2"

Test #29:

score: 0
Accepted
time: 0ms
memory: 5600kb

input:

19 6 2
00

output:

3413

result:

ok 1 number(s): "3413"

Test #30:

score: 0
Accepted
time: 1ms
memory: 5832kb

input:

19 6 1
1

output:

7012

result:

ok 1 number(s): "7012"

Test #31:

score: 0
Accepted
time: 1ms
memory: 5616kb

input:

19 12 10
1010110000

output:

266

result:

ok 1 number(s): "266"

Test #32:

score: 0
Accepted
time: 1ms
memory: 5560kb

input:

19 12 3
111

output:

19234

result:

ok 1 number(s): "19234"

Test #33:

score: 0
Accepted
time: 2ms
memory: 5932kb

input:

19 16 2
10

output:

77876

result:

ok 1 number(s): "77876"

Test #34:

score: 0
Accepted
time: 3ms
memory: 5916kb

input:

19 16 0

output:

301208

result:

ok 1 number(s): "301208"

Test #35:

score: 0
Accepted
time: 0ms
memory: 7704kb

input:

20 2 1
0

output:

1

result:

ok 1 number(s): "1"

Test #36:

score: 0
Accepted
time: 0ms
memory: 7588kb

input:

20 2 0

output:

2

result:

ok 1 number(s): "2"

Test #37:

score: 0
Accepted
time: 1ms
memory: 5868kb

input:

20 10 9
110111000

output:

76

result:

ok 1 number(s): "76"

Test #38:

score: 0
Accepted
time: 1ms
memory: 5552kb

input:

20 10 9
110101110

output:

372

result:

ok 1 number(s): "372"

Test #39:

score: 0
Accepted
time: 1ms
memory: 5724kb

input:

20 14 11
10110110000

output:

207

result:

ok 1 number(s): "207"

Test #40:

score: 0
Accepted
time: 1ms
memory: 5892kb

input:

20 14 7
0011011

output:

3675

result:

ok 1 number(s): "3675"

Test #41:

score: 0
Accepted
time: 11ms
memory: 11688kb

input:

20 20 14
10111010000000

output:

58

result:

ok 1 number(s): "58"

Subtask #2:

score: 10
Accepted

Dependency #1:

100%
Accepted

Test #42:

score: 10
Accepted
time: 2ms
memory: 5880kb

input:

114 12 11
11010000010

output:

394940507

result:

ok 1 number(s): "394940507"

Test #43:

score: 0
Accepted
time: 3ms
memory: 5688kb

input:

114 12 2
01

output:

60509873

result:

ok 1 number(s): "60509873"

Test #44:

score: 0
Accepted
time: 5ms
memory: 5700kb

input:

114 14 10
1001111011

output:

154687039

result:

ok 1 number(s): "154687039"

Test #45:

score: 0
Accepted
time: 9ms
memory: 5732kb

input:

114 14 5
00100

output:

941826071

result:

ok 1 number(s): "941826071"

Test #46:

score: 0
Accepted
time: 33ms
memory: 5804kb

input:

114 16 10
1011101001

output:

391666362

result:

ok 1 number(s): "391666362"

Test #47:

score: 0
Accepted
time: 17ms
memory: 5832kb

input:

114 16 15
000010011111010

output:

599226561

result:

ok 1 number(s): "599226561"

Test #48:

score: 0
Accepted
time: 149ms
memory: 7036kb

input:

114 18 1
0

output:

167675624

result:

ok 1 number(s): "167675624"

Test #49:

score: 0
Accepted
time: 135ms
memory: 6856kb

input:

114 18 8
11000001

output:

165986235

result:

ok 1 number(s): "165986235"

Test #50:

score: 0
Accepted
time: 472ms
memory: 11804kb

input:

114 20 17
11101000010011010

output:

852476378

result:

ok 1 number(s): "852476378"

Test #51:

score: 0
Accepted
time: 494ms
memory: 11744kb

input:

114 20 13
1101011010000

output:

974712368

result:

ok 1 number(s): "974712368"

Test #52:

score: 0
Accepted
time: 3ms
memory: 5924kb

input:

113 12 8
10101100

output:

754580060

result:

ok 1 number(s): "754580060"

Test #53:

score: 0
Accepted
time: 2ms
memory: 5624kb

input:

113 12 10
1110010010

output:

928476173

result:

ok 1 number(s): "928476173"

Test #54:

score: 0
Accepted
time: 9ms
memory: 5732kb

input:

113 14 9
010111000

output:

930953494

result:

ok 1 number(s): "930953494"

Test #55:

score: 0
Accepted
time: 10ms
memory: 5740kb

input:

113 14 0

output:

613264431

result:

ok 1 number(s): "613264431"

Test #56:

score: 0
Accepted
time: 36ms
memory: 5860kb

input:

113 16 4
0011

output:

966491874

result:

ok 1 number(s): "966491874"

Test #57:

score: 0
Accepted
time: 32ms
memory: 5928kb

input:

113 16 10
1110110011

output:

71975445

result:

ok 1 number(s): "71975445"

Test #58:

score: 0
Accepted
time: 145ms
memory: 6768kb

input:

113 18 2
01

output:

35416931

result:

ok 1 number(s): "35416931"

Test #59:

score: 0
Accepted
time: 129ms
memory: 7320kb

input:

113 18 11
01101011111

output:

605684813

result:

ok 1 number(s): "605684813"

Test #60:

score: 0
Accepted
time: 581ms
memory: 11812kb

input:

113 20 1
1

output:

970488755

result:

ok 1 number(s): "970488755"

Test #61:

score: 0
Accepted
time: 464ms
memory: 11804kb

input:

113 20 17
10000001101111001

output:

308768022

result:

ok 1 number(s): "308768022"

Test #62:

score: 0
Accepted
time: 0ms
memory: 5588kb

input:

112 12 10
1011100000

output:

379472486

result:

ok 1 number(s): "379472486"

Test #63:

score: 0
Accepted
time: 3ms
memory: 5680kb

input:

112 12 3
111

output:

876338776

result:

ok 1 number(s): "876338776"

Test #64:

score: 0
Accepted
time: 9ms
memory: 5928kb

input:

112 14 6
100111

output:

850899867

result:

ok 1 number(s): "850899867"

Test #65:

score: 0
Accepted
time: 5ms
memory: 5960kb

input:

112 14 11
11011001011

output:

579315503

result:

ok 1 number(s): "579315503"

Test #66:

score: 0
Accepted
time: 32ms
memory: 5828kb

input:

112 16 11
00000111111

output:

827780781

result:

ok 1 number(s): "827780781"

Test #67:

score: 0
Accepted
time: 33ms
memory: 6152kb

input:

112 16 9
101001101

output:

247916257

result:

ok 1 number(s): "247916257"

Test #68:

score: 0
Accepted
time: 64ms
memory: 6696kb

input:

112 18 16
0011000001111001

output:

740632908

result:

ok 1 number(s): "740632908"

Test #69:

score: 0
Accepted
time: 140ms
memory: 7336kb

input:

112 18 4
0010

output:

594108528

result:

ok 1 number(s): "594108528"

Test #70:

score: 0
Accepted
time: 536ms
memory: 11684kb

input:

112 20 7
1010100

output:

818166882

result:

ok 1 number(s): "818166882"

Test #71:

score: 0
Accepted
time: 275ms
memory: 12040kb

input:

112 20 16
0001100100101000

output:

222914924

result:

ok 1 number(s): "222914924"

Test #72:

score: 0
Accepted
time: 3ms
memory: 5924kb

input:

111 12 2
11

output:

895626591

result:

ok 1 number(s): "895626591"

Test #73:

score: 0
Accepted
time: 0ms
memory: 5676kb

input:

111 12 1
1

output:

543447881

result:

ok 1 number(s): "543447881"

Test #74:

score: 0
Accepted
time: 9ms
memory: 5676kb

input:

111 14 3
111

output:

555958815

result:

ok 1 number(s): "555958815"

Test #75:

score: 0
Accepted
time: 5ms
memory: 5672kb

input:

111 14 13
1110001101010

output:

47749667

result:

ok 1 number(s): "47749667"

Test #76:

score: 0
Accepted
time: 34ms
memory: 5860kb

input:

111 16 5
01000

output:

880732287

result:

ok 1 number(s): "880732287"

Test #77:

score: 0
Accepted
time: 30ms
memory: 6020kb

input:

111 16 7
0110010

output:

153134396

result:

ok 1 number(s): "153134396"

Test #78:

score: 0
Accepted
time: 70ms
memory: 7156kb

input:

111 18 17
11011101001111100

output:

718197735

result:

ok 1 number(s): "718197735"

Test #79:

score: 0
Accepted
time: 130ms
memory: 6624kb

input:

111 18 9
011110101

output:

78875109

result:

ok 1 number(s): "78875109"

Test #80:

score: 0
Accepted
time: 534ms
memory: 11800kb

input:

111 20 6
100101

output:

484008568

result:

ok 1 number(s): "484008568"

Test #81:

score: 0
Accepted
time: 257ms
memory: 11748kb

input:

111 20 19
1100110110001010110

output:

612558978

result:

ok 1 number(s): "612558978"

Test #82:

score: 0
Accepted
time: 443ms
memory: 11744kb

input:

102 20 10
0101000100

output:

678899105

result:

ok 1 number(s): "678899105"

Test #83:

score: 0
Accepted
time: 26ms
memory: 5748kb

input:

97 16 13
0101110011010

output:

456291266

result:

ok 1 number(s): "456291266"

Subtask #3:

score: 0
Runtime Error

Dependency #1:

100%
Accepted

Test #84:

score: 30
Accepted
time: 265ms
memory: 11800kb

input:

66 20 5
11001

output:

286180948

result:

ok 1 number(s): "286180948"

Test #85:

score: 0
Accepted
time: 99ms
memory: 11804kb

input:

66 20 19
0101001111011100100

output:

334317215

result:

ok 1 number(s): "334317215"

Test #86:

score: -30
Runtime Error

input:

66 22 19
1001101100000100001

output:


result:


Subtask #4:

score: 0
Runtime Error

Test #137:

score: 20
Accepted
time: 593ms
memory: 11800kb

input:

114 20 0

output:

849724285

result:

ok 1 number(s): "849724285"

Test #138:

score: -20
Runtime Error

input:

114 22 0

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #2:

100%
Accepted

Dependency #3:

0%