Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- #define pb push_back
- #define mp make_pair
- #define __int128 long long
- signed main()
- {
- ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
- // freopen("input.txt","r",stdin);
- // freopen("output.txt","w",stdout);
- int n;
- cin >> n;
- int p0,q0;
- cin >> p0 >> q0;
- int g = __gcd(p0,q0);
- p0 /= g;
- q0 /= g;
- vector<int> zero;
- int m,p,q;
- int a,b;
- set<pair<int,int> > st;
- map<pair<int,int>,int> pos;
- for(int i = 1; i <= n; i++)
- {
- cin >> m >> p >> q;
- g = abs(__gcd(p,q));
- p /= g;
- q /= g;
- if(p == p0 && q == q0)
- {
- zero.pb(i);
- continue;
- }
- a = m * (p0 * q - p * q0);
- b = q0 * q;
- g = __gcd(a,b);
- a /= g;
- b /= g;
- if(b < 0)
- a = -a, b = -b;
- st.insert(mp(a,b));
- pos[mp(a,b)] = i;
- }
- if(zero.size() > 1)
- {
- cout << "YES\n";
- cout << zero[0] << " " << zero[1] << "\n";
- return 0;
- }
- int k;
- pair<int,int> P;
- for(auto x : st)
- {
- P = x;
- P.first = -P.first;
- if(st.count(P))
- {
- cout << "YES\n";
- cout << pos[x] << " " << pos[P] << "\n";
- exit(0);
- }
- }
- cout << "NO";
- return 0;
- }
- /*
- n * (n+1) / 2 = M
- (n ^ 2 + n) = 2 * M
- n ^ 2 + n - 2 * M = 0
- D = 1 + 8*M
- n = (-1 + sqrt(D)) / 2
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement