Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #define int double
- using namespace std;
- bool compare(const vector<int>& a, const vector<int>& b){
- int x = (a[0] + a[1]) / 2;
- int y = (b[0] + b[1]) / 2;
- return x < y;
- }
- signed main(){
- ios_base::sync_with_stdio(false);
- cout.tie(nullptr);
- cin.tie(nullptr);
- int32_t q;
- cin >> q;
- while (q--){
- int32_t n;
- cin >> n;
- vector<vector<int>> v(n, vector<int> (3));
- for (auto& x: v){
- cin >> x[0] >> x[1] >> x[2];
- }
- sort(v.begin(), v.end(), compare);
- int32_t flag = 1;
- int left = 0, m_prev = -1;
- for (auto& x: v){
- int m = (x[0] + x[1]) / 2;
- if (m_prev == -1){
- if (m == m_prev) {
- flag = 0;
- break;
- }
- } else{
- m_prev = m;
- }
- int l = max(left, x[0]);
- if (l + x[2] > x[1]){
- flag = 0;
- break;
- }
- left = l + x[2];
- }
- cout << flag << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement