結果

問題 No.1470 Mex Sum
ユーザー Mitarushi
提出日時 2021-01-07 20:18:32
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 637 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 43,904 KB
最終ジャッジ日時 2025-01-17 10:19:13
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 TLE * 39
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         scanf("%d", &temp);
      |         ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

#include <algorithm>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

unsigned char a[200000];
int n;
using ll = long long;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int temp;
        scanf("%d", &temp);
        a[i] = 1 << std::min(temp - 1, 2);
    }
    ll lln = n;
    ll ans = lln * (lln - 1) / 2;
    for (int j = 0; j < n; j++) {
        for (int i = 0; i < j; i++) {
            unsigned char t = ~(a[i] | a[j]);
            t = (t & (-t)) - 1;
            ans += __builtin_popcount(t);
        }
    }
    printf("%lld\n", ans);
}
0