Submission #148903

# Submission time Handle Problem Language Result Execution time Memory
148903 2019-09-01T05:20:44 Z graneli(#3789, toloraia) FunctionCup Museum (FXCUP4_museum) C++17
100 / 100
126 ms 13292 KB
#include "museum.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
using namespace std;

const ll N = 1000005;

int n;
ll ans;

ll A[N], B[N], C[N];
ll AB[N], BC[N], CA[N];
ll ABC[N];

ll CountSimilarPairs(std::vector<int> a, std::vector<int> b, std::vector<int> c) {
	n = (int)a.size();
	for (int i = 0; i < n; i++){
        a[i]--;
        b[i]--;
        c[i]--;
        ll ab = a[i] * 100 + b[i];
        ll bc = b[i] * 100 + c[i];
        ll ca = c[i] * 100 + a[i];
        ll abc = a[i] * 10000 + b[i] * 100 + c[i];
        ans += A[a[i]] + B[b[i]] + C[c[i]] - AB[ab] - BC[bc] - CA[ca] + ABC[abc];
        A[a[i]]++;
        B[b[i]]++;
        C[c[i]]++;
        AB[ab]++;
        BC[bc]++;
        CA[ca]++;
        ABC[abc]++;
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 6 ms 768 KB Output is correct
5 Correct 7 ms 2048 KB Output is correct
6 Correct 8 ms 3072 KB Output is correct
7 Correct 9 ms 3840 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 10 ms 5888 KB Output is correct
10 Correct 10 ms 5760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 6 ms 768 KB Output is correct
5 Correct 7 ms 2048 KB Output is correct
6 Correct 8 ms 3072 KB Output is correct
7 Correct 9 ms 3840 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 10 ms 5888 KB Output is correct
10 Correct 10 ms 5760 KB Output is correct
11 Correct 14 ms 8192 KB Output is correct
12 Correct 17 ms 1280 KB Output is correct
13 Correct 45 ms 8700 KB Output is correct
14 Correct 55 ms 10480 KB Output is correct
15 Correct 78 ms 11504 KB Output is correct
16 Correct 84 ms 5224 KB Output is correct
17 Correct 88 ms 5484 KB Output is correct
18 Correct 96 ms 7528 KB Output is correct
19 Correct 126 ms 13288 KB Output is correct
20 Correct 124 ms 13292 KB Output is correct