QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#768855#9701. CatIllusionaryDominance#WA 252ms3532kbC++141.5kb2024-11-21 14:53:332024-11-21 14:53:34

Judging History

This is the latest submission verdict.

  • [2024-11-21 14:53:34]
  • Judged
  • Verdict: WA
  • Time: 252ms
  • Memory: 3532kb
  • [2024-11-21 14:53:33]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define all(x) (x).begin(), (x).end()

pair<set<ll>, ll> chk(ll l, ll r)
{
	set<ll> tmp;
	if (l%2==1) tmp.insert(l);
	if (r%2==0) tmp.insert(r);
	return {tmp, r-l+1-(ll)tmp.size()};
}


ll xsum[70];

void solve2(ll l, ll r, ll s)
{
	ll ans = -1;
	for (int i = l; i <= r; ++i) xsum[i-l+1] = xsum[i-l] ^ i;
	for (int i = l; i <= r; ++i) for (int j = i; j <= r; ++j) if (s >= (xsum[j-l+1] ^ xsum[i-l])) ans = max(ans, j-i+1ll);
	cout << ans << "\n";
}

void solve()
{
	ll l, r, s;
	cin >> l >> r >> s;
	if (r - l <= 32) 
	{
		solve2(l, r, s);
		return;
	}
	ll ans = 0;
	if (l == 1)
	{
		if (r==3) 
		{
			cout << 3 << "\n";
			return;
		}
		if (r > 3)
		{
			l = 4;
			ans = 3;
		}
	}
	ll L = (l-1)/4*4ll+4;
	ll R = (r+1)/4*4ll-1;
	ans += max(0ll, R-L+1);
	set<ll> o;
	vector<pair<ll, ll>> tmp;
	if (L>R) tmp.push_back({l, r});
	else 
	{
		if (l < L) tmp.push_back({l, L-1});
		if (R < r) tmp.push_back({R+1, r});
	}
	for (auto [tl, tr] : tmp) 
	{
		auto [oo, anss] = chk(tl, tr);
		// cerr << tl << " " << tr << " " << anss << "\n";
		for (auto x : oo) o.insert(x);
		assert(anss % 2 == 0);
		ll _tmp = min(anss/2, s);
		ans += _tmp * 2;
		s -= _tmp;
	}
	
	while (o.size())
	{
		ll x = *o.begin(); o.erase(x);
		if (s >= x) ++ans, s -= x;
	}
	if (ans == 0) --ans;
	cout << ans << "\n";
}

int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    
    int T;
    cin >> T;
    while (T--) solve();
}

详细

Test #1:

score: 0
Wrong Answer
time: 252ms
memory: 3532kb

input:

500000
28316250877914575 822981260158260522 1779547116602436425
335408917861648772 578223540024979445 74859962623690079
252509054433933447 760713016476190629 919845426262703496
522842184971407775 585335723211047202 148049062628894322
84324828731963982 354979173822804784 1001312150450968415
269587449...

output:

794665009280345948
242814622163330674
508203962042257183
62493538239639426
270654345090840803
376174809552329776
469882136957817192
42350729279043822
64865315101301174
697234070719324700
223517937810991677
108731400892235542
120906461794646288
463966315863716824
433607439314780607
450247658658833134...

result:

wrong answer 11th numbers differ - expected: '223517937810991678', found: '223517937810991677'