#include "museum.h"
#include <set>
#include <vector>
typedef std::pair<int, int> PII;
typedef std::set<PII> SETPAIR;
using namespace std;
long long CountSimilarPairs(std::vector<int> B, std::vector<int> T, std::vector<int> G) {
int N = B.size();
long long count = 0;
SETPAIR set_pair;
// 100 ������.
std::vector<int> BB[101];
std::vector<int> TT[101];
std::vector<int> GG[101];
for (int i = 0; i < N; ++i) {
BB[B[i]].push_back(i);
TT[T[i]].push_back(i);
GG[G[i]].push_back(i);
}
for (int i = 0; i < N; ++i) {
vector<int> &vb = BB[B[i]];
int sb = vb.size();
for (int j = 0; j < sb; ++j) {
if (i >= vb[j])
continue;
set_pair.insert(PII(i, vb[j]));
}
vector<int> &vt = TT[T[i]];
int st = vt.size();
for (int j = 0; j < st; ++j) {
if (i >= vt[j])
continue;
set_pair.insert(PII(i, vt[j]));
}
vector<int> &vg = GG[G[i]];
int sg = vg.size();
for (int j = 0; j < sg; ++j) {
if (i >= vg[j])
continue;
set_pair.insert(PII(i, vg[j]));
}
}
return (long long)set_pair.size();
for (int i = 0; i < N; ++i) {
for (int j = i + 1; j < N; ++j) {
if (B[i] == B[j]) {
set_pair.insert(PII(i, j));
++count;
continue;
}
if (T[i] == T[j]) {
set_pair.insert(PII(i, j));
++count;
continue;
}
if (G[i] == G[j]) {
set_pair.insert(PII(i, j));
++count;
continue;
}
}
}
return count;;
//return (long long)set_pair.size();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
408 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 |
7 ms |
512 KB |
Output is correct |
6 |
Correct |
8 ms |
896 KB |
Output is correct |
7 |
Correct |
10 ms |
1152 KB |
Output is correct |
8 |
Correct |
129 ms |
25848 KB |
Output is correct |
9 |
Correct |
18 ms |
3200 KB |
Output is correct |
10 |
Correct |
19 ms |
3200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
408 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 |
7 ms |
512 KB |
Output is correct |
6 |
Correct |
8 ms |
896 KB |
Output is correct |
7 |
Correct |
10 ms |
1152 KB |
Output is correct |
8 |
Correct |
129 ms |
25848 KB |
Output is correct |
9 |
Correct |
18 ms |
3200 KB |
Output is correct |
10 |
Correct |
19 ms |
3200 KB |
Output is correct |
11 |
Correct |
110 ms |
22136 KB |
Output is correct |
12 |
Execution timed out |
1111 ms |
215800 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |