#include <bits/stdc++.h>
#define gc getchar
#define gcu getchar_unlocked
#define fi first
#define se second
#define pb push_back
#define mod ((ll)1e9 + 7)
typedef long long ll;
using namespace std;
//===============================================================================================
int n, ans;
set<pair<int, int>> s[3];
map<int, int> m[3];
//===============================================================================================
int main()
{
scanf("%d", &n);
for (int i = 0, tempa, tempb, tempc; i < n; i++)
{
scanf("%d %d %d", &tempa, &tempb, &tempc);
if (s[tempa].count({tempb, tempc}))
{
ans++;
continue;
}
if (!m[tempa].count(tempb - tempc))
m[tempa][tempb - tempc] = 0;
m[tempa][tempb - tempc]++;
}
for (auto i = m[1].begin(); i != m[1].end(); i++)
if (m[2].count(i->fi))
ans += min(i->se, m[2][i->fi]);
printf("%d\n", ans);
}
//===============================================================================================
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 | #include <bits/stdc++.h> #define gc getchar #define gcu getchar_unlocked #define fi first #define se second #define pb push_back #define mod ((ll)1e9 + 7) typedef long long ll; using namespace std; //=============================================================================================== int n, ans; set<pair<int, int>> s[3]; map<int, int> m[3]; //=============================================================================================== int main() { scanf("%d", &n); for (int i = 0, tempa, tempb, tempc; i < n; i++) { scanf("%d %d %d", &tempa, &tempb, &tempc); if (s[tempa].count({tempb, tempc})) { ans++; continue; } if (!m[tempa].count(tempb - tempc)) m[tempa][tempb - tempc] = 0; m[tempa][tempb - tempc]++; } for (auto i = m[1].begin(); i != m[1].end(); i++) if (m[2].count(i->fi)) ans += min(i->se, m[2][i->fi]); printf("%d\n", ans); } //=============================================================================================== |
English