Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define pii pair<int, int>
- #define pb push_back
- #define mp make_pair
- #define f first
- #define s second
- using namespace std;
- typedef long long ll;
- const int MAXN = (int) 3e5 + 7;
- const int INF = (int) 1e9 + 7;
- int n;
- int cnt[101];
- ll solve(vector<pii> a) {
- ll res = 0;
- ll sum = 0;
- vector<int> all[101];
- for (auto it : a)
- all[it.f].pb(it.s);
- memset(cnt, 0, sizeof cnt);
- for (int x = 1; x <= 100; x++) {
- for (auto it : all[x]) {
- res += sum - cnt[it];
- }
- for (auto it : all[x])
- sum++, cnt[it]++;
- }
- return res;
- }
- vector<pii> f1[101], f2[101], f3[101];
- ll ans;
- int main() {
- #ifdef LOCAL
- freopen("in", "r", stdin);
- #else
- freopen("onlyone.in", "r", stdin);
- freopen("onlyone.out", "w", stdout);
- #endif
- scanf("%d", &n);
- for (int i = 1; i <= n; i++) {
- int x, y, z;
- scanf("%d%d%d", &x, &y, &z);
- f1[x].pb(mp(y, z));
- f2[y].pb(mp(x, z));
- f3[z].pb(mp(x, y));
- }
- for (int x = 1; x <= 100; x++) {
- ans += solve(f1[x]);
- ans += solve(f2[x]);
- ans += solve(f3[x]);
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment