Submission #70413488
Source Code Expand
#include <bits/stdc++.h>
#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void(0)
#endif
template <class T, class U = T> bool chmin(T& x, U&& y) { return y < x and (x = std::forward<U>(y), true); }
template <class T, class U = T> bool chmax(T& x, U&& y) { return x < y and (x = std::forward<U>(y), true); }
template <class T> void mkuni(std::vector<T>& v) {
std::ranges::sort(v);
auto result = std::ranges::unique(v);
v.erase(result.begin(), result.end());
}
template <class T> int lwb(const std::vector<T>& v, const T& x) {
return std::distance(v.begin(), std::ranges::lower_bound(v, x));
}
using namespace std;
using ll = long long;
void solve() {
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
map<int, int> mp;
for (int i = 0; i < N; i++) {
mp[A[i]]++;
}
ll ans = 0;
for (auto [_, cnt] : mp) {
ans += 1LL * cnt * (cnt - 1) / 2 * (N - cnt);
}
cout << ans << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
solve();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Odd One Subsequence |
| User | rniya |
| Language | C++ 23 (gcc 12.2) |
| Score | 300 |
| Code Size | 1202 Byte |
| Status | AC |
| Exec Time | 75 ms |
| Memory | 13296 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 1 ms | 3480 KiB |
| example_01.txt | AC | 1 ms | 3472 KiB |
| hand_00.txt | AC | 75 ms | 13296 KiB |
| hand_01.txt | AC | 10 ms | 3812 KiB |
| hand_02.txt | AC | 16 ms | 3836 KiB |
| hand_03.txt | AC | 1 ms | 3452 KiB |
| hand_04.txt | AC | 1 ms | 3476 KiB |
| hand_05.txt | AC | 10 ms | 3776 KiB |
| random_00.txt | AC | 61 ms | 9588 KiB |
| random_01.txt | AC | 60 ms | 9732 KiB |
| random_02.txt | AC | 60 ms | 9644 KiB |
| random_03.txt | AC | 60 ms | 9828 KiB |
| random_04.txt | AC | 61 ms | 9872 KiB |
| random_05.txt | AC | 31 ms | 4836 KiB |
| random_06.txt | AC | 32 ms | 4860 KiB |
| random_07.txt | AC | 31 ms | 4912 KiB |
| random_08.txt | AC | 31 ms | 4988 KiB |
| random_09.txt | AC | 32 ms | 4916 KiB |
| random_10.txt | AC | 16 ms | 3860 KiB |
| random_11.txt | AC | 16 ms | 3836 KiB |
| random_12.txt | AC | 17 ms | 3796 KiB |
| random_13.txt | AC | 17 ms | 3800 KiB |
| random_14.txt | AC | 16 ms | 3836 KiB |
| random_15.txt | AC | 10 ms | 3792 KiB |
| random_16.txt | AC | 10 ms | 3840 KiB |
| random_17.txt | AC | 10 ms | 3860 KiB |
| random_18.txt | AC | 10 ms | 3768 KiB |
| random_19.txt | AC | 10 ms | 3852 KiB |