Defense
Topic links: defense
Subject to the effect
You \ (n \) items, each item from three pieces of information, start, end, every time can be extended from the starting point will be to put an item on each distance extension, and now ask what position you put on is an odd number of items
Topic solution to a problem
Very bare one-half title, looked under the title bad judgment dichotomy, because the provisions of this title can only appear a bit odd, consider using a prefix, because the odd + odd = even number so like a judge, if the current position of the prefix still is odd, then to the left, or right
//#define fre yes
#include <cstdio>
#include <iostream>
const int N = 2000005;
struct Node {
long long s, e, d;
}a[N];
int n;
long long l, r;
long long check(long long x) {
long long ans = 0;
for (int i = 1; i <= n; i++) {
if(a[i].s <= x) {
ans += (std::min(x, a[i].e) - a[i].s) / a[i].d + 1;
}
} return ans;
}
int main() {
static int t;
scanf("%d", &t);
while(t--) {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d %d %d", &a[i].s, &a[i].e, &a[i].d);
}
l = 0, r = (1 << 31) - 1;
while(l < r) {
long long mid = (l + r) >> 1;
if(!(check(mid) & 1)) l = mid + 1;
else r = mid;
}
long long ans = check(r) - check(r - 1);
if(ans) {
printf("%lld %lld\n", l, ans);
} else puts("There's no weakness.");
} return 0;
}