This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "museum.h"
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <algorithm>
#include <assert.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define per(i, a, b) for(int i = b - 1; i >= a; i--)
#define ll long long
#define x first
#define y second
#define vi vector<int>
#define pii pair<int, int>
#define SZ(x) (int)(x.size())
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define mod 1000000007
#define inf 1000000007
#define DBG(x) cerr << (#x) << "=" << x << "\n";
#define N 100005
template<typename U, typename V> void Min(U &a, const V &b){if(a > b) a = b;}
template<typename U, typename V> void Max(U &a, const V &b){if(a < b) a = b;}
template<typename U, typename V> void add(U &a, const V &b){a = (a+b) % mod;}
int a[3][101], b[3][101][101], c[101][101][101];
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
int n = B.size();
rep(i, 0, n){
a[0][B[i]]++;
a[1][T[i]]++;
a[2][G[i]]++;
b[0][B[i]][T[i]]++;
b[1][B[i]][G[i]]++;
b[2][T[i]][G[i]]++;
c[B[i]][T[i]][G[i]]++;
}
ll sum = 0;
rep(i, 1, 101){
rep(j, 0, 3)if(a[j][i] >= 2)sum += (ll)a[j][i] * (a[j][i] - 1) / 2;
}
rep(i, 1, 101)rep(j, 1, 101)rep(k, 0, 3)sum -= (ll)b[k][i][j] * (b[k][i][j] - 1) / 2;
rep(i, 1, 101)rep(j, 1, 101)rep(k, 1, 101)sum += (ll)c[i][j][k] * (c[i][j][k] - 1) / 2;
return sum;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |