QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#398329#3763. Absolute Difference Equationxlwang#WA 34ms4664kbC++142.0kb2024-04-25 10:54:352024-04-25 10:54:36

Judging History

This is the latest submission verdict.

  • [2024-04-25 10:54:36]
  • Judged
  • Verdict: WA
  • Time: 34ms
  • Memory: 4664kb
  • [2024-04-25 10:54:35]
  • Submitted

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);
    if(n&1){
        if(n==1){
            if(c[1]=='1') puts("1");
            else puts("0");
            return;
        }
        int num=0;
        fr(i,2,n-1) num+=(c[i]=='?');
        if(c[1]==c[n] && c[1]!='?'){
            puts("0");
            return;
        }
        if(c[1]!='?' && c[n]!='?'){
            writeln(ksm(2,num));
            return;
        }
        num+=(c[1]=='?');num+=(c[n]=='?');--num;
        writeln(ksm(2,num));
        return;
    }
    int num=0;
    fr(i,1,n) num+=(c[i]=='?');
    if(num==0){
        fr(i,1,n) num^=(c[i]-'0');
        writeln(num);
        return;
    }
    writeln(ksm(2,num-1));
}
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;
}

详细

Test #1:

score: 0
Wrong Answer
time: 34ms
memory: 4664kb

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
0
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 6th lines differ - expected: '1', found: '0'