# 防线

 1 #include <bits/stdc++.h>
2 using namespace std;
3 const int N = 200010;
4 typedef long long ll;
5 struct seq {
6     int s, e, d;
7 } seqs[N];
8 int n;
9 ll get_sum(int x) { //get_sum返回小于等于x的数的个数
10     ll res = 0;
11     for (int i = 0; i < n; i++) { //遍历所有序列
12         if (seqs[i].s <= x) {
13             res += (min(seqs[i].e, x) - seqs[i].s) / seqs[i].d + 1;
14         }
15     }
16     return res;
17 }
18 int main() {
19     ios::sync_with_stdio(false);
20     cin.tie(0);
21     cout.tie(0);
22     int t;
23     cin >> t;
24     while (t--) {
25         int l = 0, r = 0;
26         cin >> n;
27         for (int i = 0; i < n; i++) {
28             int s, e, d;
29             cin >> s >> e >> d;
30             seqs[i] = {s, e, d};
31             r = max(r, e);
32         }
33         while (l < r) {
34             int mid = (l + r) / 2;
35             if (get_sum(mid) & 1) { //如果是奇数的话
36                 r = mid;
37             } else {
38                 l = mid + 1;
39             }
40         }
41         //看一下二分出来的这个点上的数的个数是多少
42         //小于等于l的数的个数减去小于等于l - 1的数的个数就是等于l的数的个数
43         ll sum = get_sum(l) - get_sum(l - 1);
44         if (sum & 1) { //如果是奇数，就是答案
45             cout << l << " " << sum << endl;
46         } else { //否则无解
47             cout << "There's no weakness." << endl;
48         }
49     }
50     return 0;
51 }

posted @ 2020-11-20 10:11  kyk333  阅读(110)  评论(0编辑  收藏  举报