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"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef long long ll;
#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
const int md = 1e9+7;
const ll inf = 1e18;
const int maxn = 105;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
vector< ii > goat[maxn];
int mem[maxn][maxn];
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G)
{
int n = B.size();
for(int i = 0; i< n; i++)
{
int x = B[i], y = T[i], z = G[i];
goat[x].pb(ii(y, z));
}
ll res = 0;
for(int i = 1; i<= 100; i++)
{
int k = sz(goat[i]);
res += 1LL*k*(k-1)/2;
for(ii kk : goat[i])
{
int x = kk.f, y = kk.s;
for(int j = 1; j<= 100; j++)
{
if(j == x) continue;
res += mem[j][y];
}
for(int j = 1; j<= 100; j++)
{
if(j == y) continue;
res += mem[x][j];
}
res += mem[x][y];
}
for(ii kk : goat[i])
{
int x = kk.f, y = kk.s;
mem[x][y]++;
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |