Submission #151631

# Submission time Handle Problem Language Result Execution time Memory
151631 2019-09-03T23:53:09 Z shdut FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
81 ms 11008 KB
#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
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 5 ms 660 KB Output is correct
5 Correct 6 ms 1656 KB Output is correct
6 Correct 6 ms 2168 KB Output is correct
7 Correct 6 ms 2936 KB Output is correct
8 Correct 6 ms 504 KB Output is correct
9 Correct 7 ms 4088 KB Output is correct
10 Correct 7 ms 3960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 5 ms 660 KB Output is correct
5 Correct 6 ms 1656 KB Output is correct
6 Correct 6 ms 2168 KB Output is correct
7 Correct 6 ms 2936 KB Output is correct
8 Correct 6 ms 504 KB Output is correct
9 Correct 7 ms 4088 KB Output is correct
10 Correct 7 ms 3960 KB Output is correct
11 Correct 9 ms 4600 KB Output is correct
12 Correct 15 ms 1272 KB Output is correct
13 Correct 27 ms 5876 KB Output is correct
14 Correct 38 ms 7276 KB Output is correct
15 Correct 52 ms 8556 KB Output is correct
16 Correct 69 ms 6372 KB Output is correct
17 Correct 72 ms 6504 KB Output is correct
18 Correct 76 ms 8168 KB Output is correct
19 Correct 81 ms 11008 KB Output is correct
20 Correct 81 ms 10976 KB Output is correct