QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#768796 | #9701. Cat | IllusionaryDominance# | WA | 249ms | 3676kb | C++14 | 1.0kb | 2024-11-21 14:32:23 | 2024-11-21 14:32:24 |
Judging History
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);
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: 249ms
memory: 3676kb
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'