QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#725142 | #9529. Farm Management | xydCatGirl# | WA | 0ms | 3716kb | C++20 | 1.7kb | 2024-11-08 16:25:21 | 2024-11-08 16:25:21 |
Judging History
answer
#include <bits/stdc++.h>
#define For(i, x, y) for(int i = (x); i <= (y); i++)
#define int long long
#define pb emplace_back
using namespace std;
int tot = 1;
vector< pair<int, int> > e[10005];
void solve(int l, int r, int pos) {
// assert(l <= r && l > 0);
int L = l + (l & 1), R = r - (!(r & 1));
if (L <= R) {
++ tot; e[tot].pb(pos, 0); e[tot].pb(pos, 1); solve(L / 2, R / 2, tot);
int lst = pos;
if (l != L) {
int x = l; pos = lst;
while (x) {
int v = x & 1; x >>= 1;
if (!x) e[1].pb(pos, 1);
else e[++ tot].pb(pos, v), pos = tot;
}
}
if (r != R) {
int x = r; pos = lst;
while (x) {
int v = x & 1; x >>= 1;
if (!x) e[1].pb(pos, 1);
else e[++ tot].pb(pos, v), pos = tot;
}
}
return;
} else {
// assert((r - l + 1) <= 2);
if (l == r) {
int x = l;
while (x) {
int v = x & 1; x >>= 1;
if (!x) e[1].pb(pos, 1);
else e[++ tot].pb(pos, v), pos = tot;
}
return;
}
int lst = pos, x = l;
while (x) {
int v = x & 1; x >>= 1;
if (!x) e[1].pb(pos, 1);
else e[++ tot].pb(pos, v), pos = tot;
}
pos = lst; x = r;
while (x) {
int v = x & 1; x >>= 1;
if (!x) e[1].pb(pos, 1);
else e[++ tot].pb(pos, v), pos = tot;
}
return;
}
return;
}
void Main() {
int l, r; cin >> l >> r;
tot ++; solve(l, r, 2);
cerr << tot << '\n';
// assert(tot <= 100);
int cnt = 0;
For (i, 1, tot) cnt += e[i].size();
cerr << cnt << '\n';
assert(cnt <= 200);
cout << tot << '\n';
For (i, 1, tot) {
cout << e[i].size() << ' ';
for (auto [y, v] : e[i]) cout << y << ' ' << v << ' ';
cout << '\n';
}
return;
}
signed main() {
int _ = 1;
while (_ --) Main();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3716kb
input:
5 17 2 3 4 6 1 5 8 2 4 4 3 3 7 5 5
output:
11 4 5 1 6 1 9 1 11 1 0 2 2 0 2 1 2 3 0 3 1 2 4 0 4 1 1 3 1 1 3 0 1 7 0 1 8 0 1 2 1 1 10 0
result:
wrong answer 1st lines differ - expected: '109', found: '11'