提出 #70424587


ソースコード 拡げる

// PriashisG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

    // Typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;
/*
    greater<int> for large to small
    less_equal for not unique
    finding sz-th element --> os.find_by_order(sz);                           // O(log n)
    finding the number of elements smaller than x --> os.order_by_szey(x);   // O(log n)
    os.erase(x);
*/

    // Macros
#define PB push_back
#define IN insert
#define all(x) x.begin(), x.end()
#define trav(i, a) for (auto &i : a)
#define GCD __gcd
#define F first
#define S second
#define endl '\n'
#define LB lower_bound
#define UB upper_bound
#define DEBUG(i) cout << "DEBUG " << i << "\n";
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define GT(x) greater<x>()
#define setpre(n) fixed << setprecision(n)
#define SZ(x) x.size()
#define on_bit(x) __builtin_popcount(x)

    // Functions
template <typename T> void pv(vector<T> &a){
    for (T u : a) cout << u << ' ';
    cout << '\n';
}

template <typename T> void pv2(vector<vector<T>> &a){
    trav(aa, a) pv(aa);
}

template <typename T, typename U> void pvp( vector<pair<T, U>> &a){
    trav(p, a) cout << "(" << p.F << ", " << p.S << ") ";
    cout << '\n';
}

    // Constants
const ll MOD7 = 1e9 + 7;
const ll MOD9 = 998244353;
const ll INF = LLONG_MAX;

    // Custom Functions
void fast(){
    ios::sync_with_stdio(false); cin.tie(0);
}

ll LCM(ll a, ll b){
   return (a * b) / GCD(a, b);
}

    // Custom Comparator
bool cmp(const pair<ll, ll>& x, const pair<ll, ll>& y){
    if (x.F == y.F) return x.S > y.S;
    else return x.F < y.F;
}

    // Global Variables


void solve(ll tc){

    ll n;
    cin >> n;
    
    vll v(n);
    FOR(i, 0, n) cin >> v[i];

    map<ll, ll> koita;
    for (ll i = 0; i < n; i++) koita[v[i]]++;

    ll ans = 0ll;
    trav(u, koita){
        if (u.S >= 2ll){
            ll nibo = ((u.S * (u.S - 1ll)) / 2ll) * (n - u.S);
            ans += nibo;
        }
    }

    cout << ans << "\n";


}




int main(void){

    fast(); 
    // precal();

    // freopen("final_product_chapter_1_validation_input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    ll t = 1;
    int i = 1;
    // cin >> t;
    // for (ll i = 1; i <= t; i++) 
        solve(i);

}






提出情報

提出日時
問題 C - Odd One Subsequence
ユーザ priashisg
言語 C++ 17 (gcc 12.2)
得点 300
コード長 2801 Byte
結果 AC
実行時間 117 ms
メモリ 16908 KiB

コンパイルエラー

Main.cpp: In function ‘void solve(ll)’:
Main.cpp:83:15: warning: unused parameter ‘tc’ [-Wunused-parameter]
   83 | void solve(ll tc){
      |            ~~~^~
Main.cpp: In function ‘int main()’:
Main.cpp:118:8: warning: unused variable ‘t’ [-Wunused-variable]
  118 |     ll t = 1;
      |        ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 2
AC × 28
セット名 テストケース
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 3472 KiB
example_01.txt AC 1 ms 3324 KiB
hand_00.txt AC 117 ms 16908 KiB
hand_01.txt AC 10 ms 4568 KiB
hand_02.txt AC 18 ms 4496 KiB
hand_03.txt AC 1 ms 3464 KiB
hand_04.txt AC 1 ms 3416 KiB
hand_05.txt AC 11 ms 4668 KiB
random_00.txt AC 80 ms 12496 KiB
random_01.txt AC 83 ms 12540 KiB
random_02.txt AC 85 ms 12640 KiB
random_03.txt AC 82 ms 12584 KiB
random_04.txt AC 78 ms 12488 KiB
random_05.txt AC 34 ms 5816 KiB
random_06.txt AC 34 ms 5984 KiB
random_07.txt AC 35 ms 5888 KiB
random_08.txt AC 34 ms 5904 KiB
random_09.txt AC 34 ms 5888 KiB
random_10.txt AC 18 ms 4672 KiB
random_11.txt AC 18 ms 4616 KiB
random_12.txt AC 18 ms 4724 KiB
random_13.txt AC 18 ms 4728 KiB
random_14.txt AC 18 ms 4564 KiB
random_15.txt AC 10 ms 4580 KiB
random_16.txt AC 11 ms 4592 KiB
random_17.txt AC 10 ms 4584 KiB
random_18.txt AC 10 ms 4568 KiB
random_19.txt AC 10 ms 4652 KiB