F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

View Compilation Error

0_0_23318391_5556.cpp:1:1168: fatal error: GCC4.9.2/x86_64-w64-mingw32/include/c++/bits/stdc++.h>typede: Invalid argument
 #include<bits/stdc++.h>typedef long long ll;using namespace std;const int MAXN = 2e6 + 10;int n;int a[MAXN];int root, L;int nxt[MAXN][2], cnt[MAXN][2], has[MAXN];ll sum[MAXN];ll ans;int newnode() {nxt[L][0] = nxt[L][1] = 0;return L++;}void init() {L = 1;root = newnode();memset(sum, 0, sizeof sum);memset(cnt, 0, sizeof cnt);memset(has, 0, sizeof has);}void insert(int x, int k) {int tp[32], c = 0;memset(tp, 0, sizeof tp);while(x) {tp[c++] = x % 2;x >>= 1;}int now = root;for(int i = 30; i >= 0; i--) {int d = tp[i];if(!nxt[now][d]) nxt[now][d] = newnode();now = nxt[now][d];cnt[i][d]++;sum[now] += k * cnt[i][d ^ 1];has[now] += k;}}void query(int x) {int tp[32], c = 0;memset(tp, 0, sizeof tp);while(x) {tp[c++] = x % 2;x >>= 1;}int now = root;for(int i = 30; i >= 0; i--) {int d = tp[i];int tmp = nxt[now][d ^ 1];if(tmp) {ans += sum[tmp] - 1LL * has[tmp] * cnt[i][d];}now = nxt[now][d];if(!now) break;}}int main() {int T;scanf("%d", &T);while(T--) {init();scanf("%d", &n);  for(int i = 0; i < n; i++) {scanf("%d", &a[i]);insert(a[i], 1);}ans = 0;memset(cnt, 0, sizeof cnt);for(int i = 0; i < n; i++) {insert(a[i], -1);query(a[i]);}printf("%lld\n", ans);}return 0;}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ^
compilation terminated.


Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-27 16:28:26, Gzip enabled