QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#398362 | #3763. Absolute Difference Equation | xlwang# | AC ✓ | 64ms | 4604kb | C++14 | 1.9kb | 2024-04-25 11:07:09 | 2024-04-25 11:07:10 |
Judging History
answer
#include<bits/stdc++.h>
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define foredge(i,j) for(register int i=head[j];i;i=e[i].nxt)
#define pb push_back
#define Times printf("Time:%.3lf\n",clock()/CLOCKS_PER_SEC)
using namespace std;
inline int read(){
int x=0;
bool f=0;
char c=getchar();
while(!isdigit(c)) f|=(c=='-'),c=getchar();
while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
return f?-x:x;
}
inline void write(int x){
if(x<0){putchar('-');x=-x;}
if(x>9)write(x/10);
putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline int randfind(int l,int r){return rnd()%(r-l+1)+l;}
//inline void init(){
// int t=read();
// while(t--) work();
//}
const int mod=1e9+7;
inline int ksm(int x,int y){
int sum=1;
while(y){
if(y&1) sum=1ll*sum*x%mod;
y=y/2;x=1ll*x*x%mod;
}
return sum;
}
int ans;
const int Maxn=1e6+10;
char c[Maxn];
inline void work(){
ans=0;
int n=strlen(c+1);
int num1,num2;
num1=num2=0;
if(n==1){
if(c[1]=='0') writeln(0);
else writeln(1);
return;
}
fr(i,1,n){
if(c[i]!='?') continue;
if(((n-1)&(i-1))==(i-1)) ++num1;
else ++num2;
}
// cout<<num1<<' '<<num2<<endl;
if(num1!=0) writeln(1ll*ksm(2,num1-1)*ksm(2,num2)%mod);
else {
fr(i,1,n) if(((n-1)&(i-1))==(i-1)) num1^=(c[i]-'0');
// cout<<num1<<endl;
if(num1) writeln(ksm(2,num2));
else writeln(0);
}
}
inline void init(){
while(scanf("%s",c+1)!=EOF) work();
}
signed main(){
// freopen("input.in","r",stdin);
// freopen("output.out","w",stdout);
init();
// printf("\nTIME:%.3lf",(double)clock()/CLOCKS_PER_SEC);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 64ms
memory: 4604kb
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