Submission #229254

# Submission time Handle Problem Language Result Execution time Memory
229254 2020-05-03T23:36:49 Z 534351 FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
85 ms 10856 KB
#include "museum.h"
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
int n1[3][100];
int n2[3][100][100];
int n3[100][100][100];
ll ans;

ll c2(int x)
{
    return (ll) x * (x - 1) / 2;
}

ll CountSimilarPairs(vi a, vi b, vi c)
{
	N = SZ(a);
    FOR(i, 0, N)
    {
        int x = a[i], y = b[i], z = c[i];
        x--; y--; z--;
        n1[0][x]++;
        n1[1][y]++;
        n1[2][z]++;
        n2[0][x][y]++;
        n2[1][y][z]++;
        n2[2][z][x]++;
        n3[x][y][z]++;
    }
    FOR(i, 0, 3)
    {
        FOR(j, 0, 100)
        {
            ans += c2(n1[i][j]);
        }
    }
    FOR(i, 0, 3)
    {
        FOR(j, 0, 100)
        {
            FOR(k, 0, 100)
            {
                ans -= c2(n2[i][j][k]);
            }
        }
    }
    FOR(i, 0, 100)
    {
        FOR(j, 0, 100)
        {
            FOR(k, 0, 100)
            {
                ans += c2(n3[i][j][k]);
            }
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 7 ms 640 KB Output is correct
5 Correct 7 ms 1792 KB Output is correct
6 Correct 8 ms 2176 KB Output is correct
7 Correct 8 ms 2944 KB Output is correct
8 Correct 7 ms 512 KB Output is correct
9 Correct 9 ms 3968 KB Output is correct
10 Correct 8 ms 3968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 7 ms 640 KB Output is correct
5 Correct 7 ms 1792 KB Output is correct
6 Correct 8 ms 2176 KB Output is correct
7 Correct 8 ms 2944 KB Output is correct
8 Correct 7 ms 512 KB Output is correct
9 Correct 9 ms 3968 KB Output is correct
10 Correct 8 ms 3968 KB Output is correct
11 Correct 10 ms 4608 KB Output is correct
12 Correct 17 ms 1280 KB Output is correct
13 Correct 32 ms 5884 KB Output is correct
14 Correct 40 ms 7152 KB Output is correct
15 Correct 54 ms 8432 KB Output is correct
16 Correct 72 ms 6380 KB Output is correct
17 Correct 75 ms 6508 KB Output is correct
18 Correct 78 ms 8040 KB Output is correct
19 Correct 85 ms 10856 KB Output is correct
20 Correct 83 ms 10852 KB Output is correct