#include <bits/stdc++.h> using namespace std; int horizontal[2000006]; int vertical[2000006]; int MAX=1000001; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int result=0,n; cin >> n; for(int i=0;i<n;i++){ int r,w,t; cin >> r >> w >> t; if(r==1){ if(vertical[w-t+MAX]<horizontal[w-t+MAX])result++; vertical[w-t+MAX]++; } else{ if(horizontal[w-t+MAX]<vertical[w-t+MAX])result++; horizontal[w-t+MAX]++; } } cout << result << "\n"; 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 horizontal[2000006]; int vertical[2000006]; int MAX=1000001; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int result=0,n; cin >> n; for(int i=0;i<n;i++){ int r,w,t; cin >> r >> w >> t; if(r==1){ if(vertical[w-t+MAX]<horizontal[w-t+MAX])result++; vertical[w-t+MAX]++; } else{ if(horizontal[w-t+MAX]<vertical[w-t+MAX])result++; horizontal[w-t+MAX]++; } } cout << result << "\n"; return 0; } |