QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#959392#3763. Absolute Difference Equationi_love_qingyu#AC ✓157ms5208kbC++20516b2025-03-31 18:47:112025-03-31 18:47:12

Judging History

This is the latest submission verdict.

  • [2025-03-31 18:47:12]
  • Judged
  • Verdict: AC
  • Time: 157ms
  • Memory: 5208kb
  • [2025-03-31 18:47:11]
  • Submitted

answer

#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
int mi(int x,int y){
    int sum=1;
    while(y){
        if(y&1)sum=sum*x%mod;
        x=x*x%mod;
        y>>=1;
    }return sum;
}
signed main(){
    string s;
    while(cin>>s){
        int n=s.size(),a=0,b=0,p=0;
        for(int i=0;i<n;i++)if((i&(n-1))==i&&s[i]=='?')a++;else if(s[i]=='?')b++;else if((i&(n-1))==i)p^=s[i]-48;
        cout<<mi(2,b)*(a>0?mi(2,a-1):p)%mod<<'\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 157ms
memory: 5208kb

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:

ok 162656 lines