QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#385326#3763. Absolute Difference Equation秦始皇派蒙恬还原神舟十二 (Jiancong Wen, Chu Jin, Zekai Zhang)WA 21ms12320kbC++171.1kb2024-04-10 17:40:172024-04-10 17:40:19

Judging History

This is the latest submission verdict.

  • [2024-04-10 17:40:19]
  • Judged
  • Verdict: WA
  • Time: 21ms
  • Memory: 12320kb
  • [2024-04-10 17:40:17]
  • Submitted

answer

#include<bits/stdc++.h>
#define mem(i,a) memset(i,a,sizeof(i))
#define inf 0x3f3f3f3f3f3f3f3f
#define PII pair<int,int>
#define int  long long
#define endl '\n'
using namespace std;
const int maxn = 1e6 + 5,mod=1e9+7;
int f[maxn];
void solve() {
	string s;
	while(cin>>s){
		string s2;
		int n=s.size();
		if(n==1){
			if(s=="1"||s=="?")cout<<1<<endl;
			else cout<<0<<endl;
			continue;
		}
		// if(n%2==0){
			// for(int i=0;i<n-1;i++){
				// if(s[i]=='?'||s[i+1]=='?')s2+='?';
				// else{
					// int a=s[i]-'0',b=s[i+1]-'0';
					// a=abs(a-b);
					// s2+=(a+'0');
				// }
			// }
			// s=s2;
			// cout<<s2<<endl;
		// }
		int sum=0;
		for(int i=1;i<(n-1);i++){
			sum+=(s[i]=='?');
		}
		int ans=0;
		if((s[0]=='1'||s[0]=='?')&&(s.back()=='0'||s.back()=='?')){
			if(n%2==1)ans=(ans+f[sum]);
			else ans=(ans+f[max(0ll,sum-1)]);
		}
		if((s[0]=='0'||s[0]=='?')&&(s.back()=='1'||s.back()=='?')){
			if(n%2==1)ans=(ans+f[sum])%mod;
			else ans=(ans+f[max(0ll,sum-1)])%mod;
		}
		cout<<ans<<endl;
	}
	
}
signed main() {
	f[0]=1;
	for(int i=1;i<=1000000;i++){
		f[i]=f[i-1]*2%mod;
	}
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(0);
		solve();
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 21ms
memory: 12320kb

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