結果

問題 No.694 square1001 and Permutation 3
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-06-24 14:38:31
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 690 bytes
コンパイル時間 922 ms
コンパイル使用メモリ 73,664 KB
実行使用メモリ 32,748 KB
最終ジャッジ日時 2023-09-13 13:41:01
合計ジャッジ時間 8,569 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,760 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 783 ms
7,320 KB
testcase_08 AC 1,548 ms
9,636 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int a[500000], b[500000];
int main(){
    cin.tie(0), ios_base::sync_with_stdio(false); 
    int n;
    cin >> n;
    for(int i=0; i<n; ++i) cin >> a[i];
    long long r = 0;
    for(int i=29; i>=0; --i){
        map<int,int> c;
        for(int j=0; j<n; ++j){
            if(!(a[j]>>i&1)) r += c[a[j]>>i+1];
            else c[a[j]>>i+1] += 1;
        }
    }
    for(int i=0; i<n; ++i) b[i] = a[i];
    sort(b, b+n);
    for(int i=0; i<n; ++i){
        cout << r << endl;
        int l = lower_bound(b, b+n, a[i]) - b;
        int u = upper_bound(b, b+n, a[i]) - b;
        r += (n-u) - l;
    }
    return 0;
}
0