Submission #148820

# Submission time Handle Problem Language Result Execution time Memory
148820 2019-09-01T05:11:38 Z From The Sky(#3630, WhipppedCream, top34051, zoomswk) FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
137 ms 7532 KB
#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
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 8 ms 512 KB Output is correct
9 Correct 7 ms 512 KB Output is correct
10 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 8 ms 512 KB Output is correct
9 Correct 7 ms 512 KB Output is correct
10 Correct 7 ms 512 KB Output is correct
11 Correct 10 ms 512 KB Output is correct
12 Correct 36 ms 1528 KB Output is correct
13 Correct 45 ms 2548 KB Output is correct
14 Correct 61 ms 3180 KB Output is correct
15 Correct 82 ms 4848 KB Output is correct
16 Correct 121 ms 7272 KB Output is correct
17 Correct 121 ms 7532 KB Output is correct
18 Correct 126 ms 6884 KB Output is correct
19 Correct 137 ms 7016 KB Output is correct
20 Correct 128 ms 7140 KB Output is correct