結果

問題 No.694 square1001 and Permutation 3
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-06-24 14:34:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 633 bytes
コンパイル時間 3,165 ms
コンパイル使用メモリ 72,552 KB
実行使用メモリ 33,132 KB
最終ジャッジ日時 2023-09-13 13:40:42
合計ジャッジ時間 9,759 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
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(){
    int n;
    cin >> n;
    for(int i=0; i<n; ++i) cin >> a[i];
    int 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