Transmission Door
Unexpectedly double 叒 叕 is the permission question ...
The topic is very long ah.
There are also a number of teaching assessment missions on the road, for each of the assessment missions from the beginning of each D station one person until E end, now to find a station of the number of odd points, this point may not, at most only one, ask this point where and how many people stand at this point.
If not Lyd Blue book tells me he is two points, I would like to go to the line tree.
To think about it, I overlooked one of the most important conditions: at most there is only one odd number of points.
Monotonicity. Monotonicity. There it is. Prefixes and.
So all we have to do is maintain a prefix and, because there is only one odd number, and the others are even numbered prefixes and certainly odd numbers. So we just need a second division to find the smallest prefix and the odd position is no good. The complexity of the prefix and is O (n) o (n) o (n) then the second point is O (logn) O (L o g N) O (logn), so the final complication is O (NLOGN) o (n l o g N) O (NLOGN)
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <
Cmath> using namespace std;
typedef long Long LL;
const int maxn=200010; struct Node {ll s,d,e;}
A[MAXN];
int n;
ll Getsum (ll limit) {ll ans=0;
for (int i=1;i<=n;i++) {if (a[i].s>limit) continue;
ll R=min (A[i].e,limit);
ans+= (R-A[I].S)/a[i].d+1;
return ans;
int main () {int t;scanf ("%d", &t);
while (t--) {//computes the prefix and, because only one place is an odd number, as long as the binary prefix and the first odd prefix and point can be found (monotonicity is reflected in the prefix and) scanf ("%d", &n);
ll limit=0;
for (int i=1;i<=n;i++) {scanf ("%lld%lld%lld", &A[I].S,&A[I].E,&A[I].D);
Limit=max (LIMIT,A[I].E);
ll sum=getsum (limit); if (!) (
sum&1)) {printf ("Poor QIN Teng: (\ n"); continue;}
ll L=0,r=limit,ans=0;
while (L<=r) {ll mid= (l+r)/2;
if (Getsum (mid) &1) {ans=mid; r=mid-1;}
else l=mid+1;
ll cnt=0; for (int i=1;i<=n;i++) {if (A[i].s>ans) continue;
if (A[i].e<ans) continue;
if ((ANS-A[I].S)%a[i].d==0) cnt++;
printf ("%lld%lld\n", ans,cnt);
return 0; }