QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#281413#7789. Outro: True Love Waitsucup-team2894#WA 0ms3824kbC++201.7kb2023-12-10 04:19:572023-12-10 04:19:58

Judging History

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

  • [2023-12-10 04:19:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3824kb
  • [2023-12-10 04:19:57]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;
using pii = pair<int,int>;
using ll = long long;
using ull = unsigned long long;
using lll = __int128;
using pll = pair<ll,ll>;
using vi = vector<int>;

#define fr first 
#define sc second

using ld = long double;

#define all(x) (x).begin(), (x).end()

const int maxn = 1e6+10, inf = 1e9+100;
const ll linf = 8e18+100;
const int mod = 1e9+7;



//  #define cerr if(0) cerr

ll po(ll a,ll b){
	ll ans = 1;
	for(a%=mod;b;b>>=1,a=a*a%mod)if(b&1)ans=ans*a%mod;
	return ans;
}

ll inv(ll a){
	return po(a,mod-2);
}

ll num4s(ll n){
	return (po(4,n+1)-1)*inv(3)%mod;
}

void solve () {
	string s,t;
	ll k;
	cin >> s >> t >> k;
	reverse(all(s));
	reverse(all(t));
	s.resize(max(s.size(),t.size()), '0');
	t.resize(s.size(), '0');
	for(int i=0;i<s.size();i++)s[i]^=t[i];
	if(s.size()%2)s.push_back(0);
	int numdz = 0;
	bool iszero = true;
	// for(int i=0;i<s.size();i++)cerr << int(s[i]) << " ";
	for(int i=0;i<s.size();i++){
		
		if(s[i]==0)numdz++;
		else {
			iszero = false;
			break;
		}
	}
	// cerr << endl;
	numdz /= 2;
	k--;
	if(iszero) {
		ll ans =  ( num4s(k)-1)%mod;
		if(ans<0)ans+=mod;
		cout << ans << "\n";
		return;
	}
	if(k>numdz){
		cout << "-1\n";
		return;
	}
	ll ans = 0;
	for(int i=numdz;i*2<s.size();i+=2){
		int num = s[2*i+1]*2+(s[2*i+1]^s[2*i]);
		ans = (ans + num * num4s(i)) %mod;
	}
	ans =  (ans + num4s(k)-1)%mod;
	if(ans<0)ans+=mod;
	cout << ans << "\n";
}


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout<<fixed;
  cout.precision(20);
	int tc;
	cin >> tc;
	while(tc--)
  solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3564kb

input:

4
1 10 1
1 10 2
100 0 2
11 11 3

output:

2
-1
9
20

result:

ok 4 number(s): "2 -1 9 20"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

1
0 0 1

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3824kb

input:

100
110111 11111 1
10110 101101 1
11010 111111 1
100110 1 1
10010 11010 1
1100 10111 1
100100 111110 1
101110 101100 1
1011 10110 1
110100 1110 1
11010 11000 1
11110 1000 1
111000 11101 1
110 1001 1
101010 11000 1
10 111110 1
110001 101000 1
1010 1000 1
10101 11 1
111011 11010 1
110001 100000 1
1100...

output:

15
44
64
65
15
23
24
3
22
45
3
24
64
2
45
10
22
3
24
64
22
24
44
64
65
22
23
66
24
3
15
3
66
15
23
65
64
15
3
23
24
42
64
44
1
0
63
3
24
15
10
1
65
24
22
44
66
3
23
10
21
24
23
43
21
5
2
44
42
3
22
65
44
24
45
24
24
23
24
65
45
1
44
5
24
3
64
45
3
5
64
43
22
1
3
22
2
5
42
44

result:

wrong answer 1st numbers differ - expected: '78', found: '15'