QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#768903#9701. CatIllusionaryDominance#WA 208ms3872kbC++141.2kb2024-11-21 15:09:322024-11-21 15:09:39

Judging History

This is the latest submission verdict.

  • [2024-11-21 15:09:39]
  • Judged
  • Verdict: WA
  • Time: 208ms
  • Memory: 3872kb
  • [2024-11-21 15:09:32]
  • Submitted

answer

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

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

#define int long long

ll xsum[70];

void solve2(ll l, ll r, ll s)
{
	ll ans = -1;
	for (ll i = l; i <= r; ++i) xsum[i-l+1] = xsum[i-l] ^ i;
	for (ll i = l; i <= r; ++i) for (ll 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;
	assert(L < R);
	int xx=0;
	if (L-2>=l) L-=2, ++xx;
	if (R+2<=r) R+=2, ++xx;
	if (xx==2) ans += 4;
	else if (xx==1) if(s) s-=1, ans+=2;
	
	for (ll i = l; i < L; ++i) o.insert(i);
	for (ll j = R+1; j <= r; ++j) o.insert(j); 
	
	while (o.size())
	{
		ll x = *o.begin(); o.erase(x);
		if (s >= x) ++ans, s -= x;
	}
	if (ans == 0) --ans;
	cout << ans << "\n";
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 208ms
memory: 3872kb

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'