QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#768787#9701. CatIllusionaryDominance#WA 247ms3648kbC++141001b2024-11-21 14:28:562024-11-21 14:28:56

Judging History

This is the latest submission verdict.

  • [2024-11-21 14:28:56]
  • Judged
  • Verdict: WA
  • Time: 247ms
  • Memory: 3648kb
  • [2024-11-21 14:28:56]
  • 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()};
}

void solve()
{
	ll l, r, s;
	cin >> l >> r >> s;
	ll L = (l-1)/4*4ll+4;
	ll R = r/4*4ll-1;
	ll 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);
		ans += anss;
	}
	
	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();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 247ms
memory: 3648kb

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'