QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#769082#8330. Count off 3HokTL 0ms0kbC++232.6kb2024-11-21 16:03:142024-11-21 16:03:14

Judging History

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

  • [2024-11-21 16:03:14]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-21 16:03:14]
  • 提交

answer

#include<bits/stdc++.h>
#define ls (p<<1)
#define rs (ls|1)
#define mid ((l+r)>>1)
#define int long long
using namespace std;
const int N=117649+10,V=117649,M=11,INF=1e12,mod=1e9+7;
char qwq;
int tt,t[2][N],f[2][N],ans[N],q[M][N],l[N];
char s[M][N];
char qwqq;
namespace Fast_IO
{
    static char buf[1000000],*paa=buf,*pd=buf,out[10000000];int length=0;
    #define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
    inline int read()
    {
        int x(0),t(1);char fc(getchar());
        while(!isdigit(fc)){if(fc=='-') t=-1;fc=getchar();}
        while(isdigit(fc)) x=(x<<1)+(x<<3)+(fc^48),fc=getchar();
        return x*t;
    }
    inline void flush(){fwrite(out,1,length,stdout);length=0;}
    inline void put(char c){if(length==9999999) flush();out[length++]=c;}
    inline void put(string s){for(char c:s) put(c);}
    inline void print(long long x)
    {
        if(x<0) put('-'),x=-x;
        if(x>9) print(x/10);
        put(x%10+'0');
    }
    inline bool chk(char c) { return !(c>='a'&&c<='z'||c>='A'&&c<='Z'||c>='0'&&c<='9'||c==','||c=='!'||c=='_'||c=='.'||c=='-'); }
    inline bool ck(char c) { return c!='\n'&&c!='\r'&&c!=-1&&c!=' '; }
    inline void rd(char s[],int&n)
    {
        s[++n]=getchar();
        while(chk(s[n])) s[n]=getchar();
        while(ck(s[n])) s[++n]=getchar();
        n--;
    }
}
using namespace Fast_IO;
inline int get(int x,int w){int s=0;for(int i=1,op=1;i<7;i++) s+=op*((x%7*i+w)%7),x/=7,op*=7;return s;}
inline bool ck(int s){for(int i=1;i<7;i++){if(s%7==0) return false;s/=7;}return true;}
inline void dp(int i)
{
    memset(f[1-i],0,sizeof(f[1-i]));tt++;
    for(int j=0;j<=V;j++) f[1-i][t[0][j]]+=f[i][j],f[1-i][t[1][j]]+=f[i][j];
    if(tt==30){for(int j=0;j<V;j++) f[1-i][j]%=mod;tt=0;}
}
inline void solve()
{
    for(int i=0;i<V;i++) t[0][get(i,0)]=i,t[1][get(i,1)]=i;
    int T=read();for(int i=1;i<=T;i++) rd(s[i],l[i]);
    for(int i=1,st=0;i<=T;i++)
    {
        for(int j=1;j<=l[i];j++)
            if(s[i][j]=='1') q[i][l[i]-j]=get(st,0),st=get(st,1);
            else q[i][l[i]-j]=-1,st=get(st,0);
        ans[i]+=(ck(st)&&s[i][l[i]]=='1');st=0;
    }for(int i=0;i<V;i++) f[1][i]=ck(get(i,1));
    for(int i=1;i<10001;i++)
    {
        for(int j=1;j<=T;j++) if(i<l[j]&&q[j][i]!=-1)
            ans[j]=(ans[j]+f[i%2][q[j][i]])%mod;dp(i%2);
    }for(int i=1;i<=T;i++) print(ans[i]),put('\n');
}
signed main()
{
    int T=1;
    // cout<<(&qwqq-&qwq)/1024.0/1024.0<<endl;
    // T=read();
    while(T--) solve();
    genshin:;flush();return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

5
1
1010
110101
1000111000
101101001000

output:

1
2
15
114
514

result: