#include<bits/stdc++.h>
#define ST first
#define ND second
#define ll long long
#define ld long double
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;
const ll INF = 1e9 + 9;
const ll MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;
// secik.insert({x, t++});
// secik.erase(secik.lower_bound({x,-1}));
// *secik.find_by_order(x)).first << "\n";
// secik.order_of_key(x)
//random_device device;
//mt19937 gener(device());
//uniform_int_distribution<ll > gen(0,n-1);
//gen(gener); // generate random number
const int SIZE = 5e5 + 5;
ll minxd[SIZE];
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n; cin >> n;
set<int> secior;
set<pair<int,int> > secior1,secior2;
map<int,int> mapa1,mapa2;
for(int i = 1; i <= n; i++){
int t; cin >> t;
int x,y; cin >> x >> y;
if(t == 1){
secior1.insert({x,y});
mapa1[x-y]++;
} else {
secior2.insert({x,y});
mapa2[x-y]++;
}
secior.insert(x-y);
}
int ans = n - secior1.size() - secior2.size();
for(auto it : secior)
ans += min(mapa1[it],mapa2[it]);
cout << ans;
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #include<bits/stdc++.h> #define ST first #define ND second #define ll long long #define ld long double #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " using namespace std; const ll INF = 1e9 + 9; const ll MOD = 1e9 + 7; const long long LINF = (ll)1e18 + 3; // secik.insert({x, t++}); // secik.erase(secik.lower_bound({x,-1})); // *secik.find_by_order(x)).first << "\n"; // secik.order_of_key(x) //random_device device; //mt19937 gener(device()); //uniform_int_distribution<ll > gen(0,n-1); //gen(gener); // generate random number const int SIZE = 5e5 + 5; ll minxd[SIZE]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; set<int> secior; set<pair<int,int> > secior1,secior2; map<int,int> mapa1,mapa2; for(int i = 1; i <= n; i++){ int t; cin >> t; int x,y; cin >> x >> y; if(t == 1){ secior1.insert({x,y}); mapa1[x-y]++; } else { secior2.insert({x,y}); mapa2[x-y]++; } secior.insert(x-y); } int ans = n - secior1.size() - secior2.size(); for(auto it : secior) ans += min(mapa1[it],mapa2[it]); cout << ans; return 0; } |
English