Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC target("avx,avx2")
- #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
- #pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,tune=native")
- #pragma GCC optimize("03")
- #include <iostream>
- #include <vector>
- #include <cmath>
- #include <numeric>
- #include <algorithm>
- #include <unordered_set>
- #include <unordered_map>
- #include <set>
- #include <map>
- #include <queue>
- #include <deque>
- #include <bitset>
- #include <stack>
- #include <random>
- #define pb push_back
- #define ll long long
- #define ld long double
- #define all(a) a.begin(), a.end()
- #define sz(a) (int)a.size()
- using namespace std;
- //tg: @galebickosikasa
- const int maxn = (int)3e5;
- const int inf = (int)2e9;
- const ld eps = 1e-9;
- mt19937 SuperRandom;
- struct Segment{
- ld l, r, t;
- };
- bool comp(const Segment& a, const Segment& b){
- ld m1 = (a.l + a.r) / 2, m2 = (b.l + b.r) / 2;
- return m1 < m2;
- }
- int kek(const vector<Segment>& goo){
- ld l = 0, m_prev = -1;
- for (auto& x: goo){
- if (m_prev != -1){
- ld m = (x.l + x.r) / 2;
- if (m_prev == m) return 0;
- m_prev = m;
- } else{
- m_prev = (x.l + x.r) / 2;
- }
- ld l_tmp = max(l, x.l);
- if (l_tmp + x.t > x.r) return 0;
- l = l_tmp + x.t;
- }
- return 1;
- }
- istream& operator >> (istream& in, Segment& s){
- in >> s.l >> s.r >> s.t;
- return in;
- }
- int main(){
- ios_base::sync_with_stdio(false);
- cout.tie(nullptr);
- cin.tie(nullptr);
- int q;
- cin >> q;
- while (q--){
- int n;
- cin >> n;
- vector<Segment> goo(n);
- for (auto& x: goo) cin >> x;
- sort(all(goo), comp);
- cout << kek(goo) << '\n';
- }
- }
- /*
- 2
- 2
- 1 7 4
- 1 3 2
- 2
- 1 6 4
- 1 3 2
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement