#include <bits/stdc++.h> using namespace std; int n; pair<pair<int, int>, int>A[500005]; set<int>Poz[2]; int wynik; int ile[2][2000006], d=1000002; int main() { cin>>n; for (int i=0; i<n; ++i){ cin>>A[i].second>>A[i].first.second>>A[i].first.first; ++ile[A[i].second%2][A[i].first.second-A[i].first.first+d]; } for (int i=0; i<2000006; ++i) if (ile[0][i]>0&&ile[1][i]>0) wynik+=min(ile[0][i],ile[1][i]); cout<<wynik; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #include <bits/stdc++.h> using namespace std; int n; pair<pair<int, int>, int>A[500005]; set<int>Poz[2]; int wynik; int ile[2][2000006], d=1000002; int main() { cin>>n; for (int i=0; i<n; ++i){ cin>>A[i].second>>A[i].first.second>>A[i].first.first; ++ile[A[i].second%2][A[i].first.second-A[i].first.first+d]; } for (int i=0; i<2000006; ++i) if (ile[0][i]>0&&ile[1][i]>0) wynik+=min(ile[0][i],ile[1][i]); cout<<wynik; return 0; } |