提出 #70432357
ソースコード 拡げる
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pii pair<int,int>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int MOD = 1000000007;
const int INF = 1e18;
const int N = 2e5;
/*
total pairs nC3 -
# all same (freq[x] C 3)
# all different
*/
int xc2(int x){
if(x < 2)return 0;
int res = x * (x - 1) / 2;
return res;
}
void solve(int tc) {
int n; cin >> n;
int sum = 0;
map<int,int>mp;
for(int i=0;i<n;i++){
int x; cin >> x;
mp[x]++;
}
for(auto it : mp){
sum += xc2(it.ss);
}
int ans = 0;
for(auto it : mp){
ans += it.ss * (sum - xc2(it.ss));
}
cout << ans << endl;
}
int32_t main() {
Fast
int t = 1;
// cin >> t;
for (int tc = 1; tc <= t; tc++)
solve(tc);
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Odd One Subsequence |
| ユーザ | H_R_K |
| 言語 | C++ 20 (gcc 12.2) |
| 得点 | 300 |
| コード長 | 1055 Byte |
| 結果 | AC |
| 実行時間 | 94 ms |
| メモリ | 15936 KiB |
コンパイルエラー
Main.cpp: In function ‘void solve(long long int)’:
Main.cpp:26:16: warning: unused parameter ‘tc’ [-Wunused-parameter]
26 | void solve(int tc) {
| ^
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| example_00.txt | AC | 1 ms | 3500 KiB |
| example_01.txt | AC | 1 ms | 3352 KiB |
| hand_00.txt | AC | 94 ms | 15936 KiB |
| hand_01.txt | AC | 9 ms | 3436 KiB |
| hand_02.txt | AC | 17 ms | 3480 KiB |
| hand_03.txt | AC | 1 ms | 3624 KiB |
| hand_04.txt | AC | 1 ms | 3496 KiB |
| hand_05.txt | AC | 9 ms | 3424 KiB |
| random_00.txt | AC | 74 ms | 11388 KiB |
| random_01.txt | AC | 73 ms | 11524 KiB |
| random_02.txt | AC | 72 ms | 11308 KiB |
| random_03.txt | AC | 71 ms | 11344 KiB |
| random_04.txt | AC | 73 ms | 11344 KiB |
| random_05.txt | AC | 34 ms | 4744 KiB |
| random_06.txt | AC | 35 ms | 4744 KiB |
| random_07.txt | AC | 34 ms | 4748 KiB |
| random_08.txt | AC | 35 ms | 4744 KiB |
| random_09.txt | AC | 34 ms | 4672 KiB |
| random_10.txt | AC | 16 ms | 3532 KiB |
| random_11.txt | AC | 16 ms | 3472 KiB |
| random_12.txt | AC | 16 ms | 3520 KiB |
| random_13.txt | AC | 16 ms | 3600 KiB |
| random_14.txt | AC | 16 ms | 3516 KiB |
| random_15.txt | AC | 10 ms | 3444 KiB |
| random_16.txt | AC | 9 ms | 3532 KiB |
| random_17.txt | AC | 10 ms | 3424 KiB |
| random_18.txt | AC | 10 ms | 3424 KiB |
| random_19.txt | AC | 9 ms | 3560 KiB |