QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#398293#3763. Absolute Difference EquationGraphcity#WA 283ms13548kbC++201.1kb2024-04-25 10:26:542024-04-25 10:26:55

Judging History

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

  • [2024-04-25 10:26:55]
  • 评测
  • 测评结果:WA
  • 用时:283ms
  • 内存:13548kb
  • [2024-04-25 10:26:54]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rof(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int Maxn=1e6,Mod=1e9+7;

inline int Pow(int x,int y)
{
    int res=1;
    while(y)
    {
        if(y&1) res=1ll*res*x%Mod;
        x=1ll*x*x%Mod,y>>=1;
    }
    return res;
}

int fac[Maxn+5],inv[Maxn+5],n; string s;

inline void Solve()
{
    n=s.size(),s=' '+s;
    int f[2]={1,0};
    For(i,1,n)
    {
        int k=1ll*fac[n-1]*inv[i-1]%Mod*inv[n-i]%Mod;
        if(k%2==0)
        {
            f[0]=(1ll+(s[i]=='?'))*f[0]%Mod;
            f[1]=(1ll+(s[i]=='?'))*f[1]%Mod;
        }
        else
        {
            int g0=0,g1=0;
            if(s[i]!='1') (g0+=f[0])%=Mod,(g1+=f[1])%=Mod;
            if(s[i]!='0') (g1+=f[0])%=Mod,(g0+=f[1])%=Mod;
            f[0]=g0,f[1]=g1;
        }
    } cout<<f[1]<<endl;
}

int main()
{
    // freopen("1.in","r",stdin);

    fac[0]=inv[0]=1;
    For(i,1,Maxn) fac[i]=1ll*fac[i-1]*i%Mod;
    inv[Maxn]=Pow(fac[Maxn],Mod-2);
    Rof(i,Maxn-1,1) inv[i]=1ll*inv[i+1]*(i+1)%Mod;
    while(cin>>s) Solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 283ms
memory: 13548kb

input:

1
?????
1010?1?0
0
1
?
00
10
?0
01
11
?1
0?
1?
??
000
100
?00
010
110
?10
0?0
1?0
??0
001
101
?01
011
111
?11
0?1
1?1
??1
00?
10?
?0?
01?
11?
?1?
0??
1??
???
0000
1000
?000
0100
1100
?100
0?00
1?00
??00
0010
1010
?010
0110
1110
?110
0?10
1?10
??10
00?0
10?0
?0?0
01?0
11?0
?1?0
0??0
1??0
???0
0001
10...

output:

1
16
2
0
1
1
0
1
1
1
0
1
1
1
2
0
1
1
0
1
1
0
2
2
1
0
1
1
0
1
2
0
2
1
1
2
1
1
2
2
2
4
0
1
1
1
0
1
1
1
2
1
0
1
0
1
1
1
1
2
1
1
2
1
1
2
2
2
4
1
0
1
0
1
1
1
1
2
0
1
1
1
0
1
1
1
2
1
1
2
1
1
2
2
2
4
1
1
2
1
1
2
2
2
4
1
1
2
1
1
2
2
2
4
2
2
4
2
2
4
4
4
8
0
1
1
0
1
1
0
2
2
0
1
1
0
1
1
0
2
2
0
2
2
0
2
2
0
4
4...

result:

wrong answer 155337th lines differ - expected: '185921272', found: '92960636'