제출 #772651

#제출 시각아이디문제언어결과실행 시간메모리
772651FilyaXOR Sum (info1cup17_xorsum)C++14
45 / 100
1631 ms127104 KiB
//♥God will make a way♥ //#include <bits/stdc++.h> #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #include <algorithm> #include <cmath> #include <cstring> #include <cassert> #include <set> #include <map> #include <unordered_map> #include <vector> #include <stack> #include <queue> #include <iomanip> #include <bitset> #include <stdio.h> #include <climits> #include <numeric> using namespace std; //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; //template <typename T> //using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; /////////////////////define///////////////////// #define ci(x) if(x) cout << "YES" << '\n'; else cout << "NO" << '\n'; #define cii(x) if(check(x)) #define MOD 1000000007 #define MOD2 998244353 #define oo 1e9 #define ool 1e18L #define pii pair<int, int> #define pll pair<long long, long long> #define mii map<int, int> #define vi vector<int> #define vpi vector<pair<int, int>> #define vll vector <ll> #define ff first #define ss second #define mp make_pair #define ll long long #define ld long double #define pb push_back #define eb emplace_back #define pob pop_back #define lb lower_bound #define ub upper_bound #define bs binary_search #define sz(x) (int((x).size())) #define all(x) (x).begin(), (x).end() #define alll(x) (x), (x) + n #define clr(x) (x).clear(); #define fri(x) for(int i = 0; i < x; ++i) #define frj(x) for(int j = 0; j < x; ++j) #define frp(x) for(int p = 0; p < x; ++p) #define frr(a, b) for(int i = a; i < b; ++i) #define frrj(a, b) for(int j = a; j < b; ++j) #define fra(x) for(int i = 0; i < x; ++i) cin >> a[i]; #define frb(x) for(int i = 0; i < x; ++i) cin >> b[i]; #define frs(x) for(auto it = x.begin(); it != x.end(); ++it) #define fr(x) for(auto it : x) //el #define fastio ios_base::sync_with_stdio(false); cin.tie(0); #define dbg(x) cerr << #x << ": " << x << endl; #define ce(x) cout << x << endl; #define uniq(x) x.resize(unique(all(x)) - x.begin()); //make all one after sorting #define blt __builtin_popcount /////////////////////print array, vector, deque, set, multiset, pair, map ///////////////////// void print(long long t) {cerr << t;} void print(int t) {cerr << t;} void print(string t) {cerr << t;} void print(char t) {cerr << t;} void print(double t) {cerr << t;} void print(long double t) {cerr << t;} void print(unsigned long long t) {cerr << t;} template <class T, class V> void print(pair <T, V> p) {cerr << "{"; print(p.first); cerr << ","; print(p.second); cerr << "}";} template <class T, class V> void print(T v[],V n) {cerr << "["; for(int i = 0; i < n; i++) {print(v[i]); cerr << " "; } cerr << "]"; cout << endl;} template <class T> void print(vector <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;} template <class T> void print(set <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;} template <class T> void print(multiset <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;} template <class T> void print(stack <T> v) {cerr << "[ "; stack<T> s = v; while(s.size()) {T i = s.top(); print(i); s.pop(); cerr << " ";} cerr << "]"; cout << endl;} template <class T> void print(queue <T> v) {cerr << "[ "; queue<T> s = v; while(s.size()) {T i = s.front(); print(i); s.pop(); cerr << " ";} cerr << "]"; cout << endl;} template <class T> void print(deque <T> v) {cerr << "[ "; deque<T> s = v; while(s.size()) {T i = s.front(); print(i); s.pop_front(); cerr << " ";} cerr << "]"; cout << endl;} template <class T, class V> void print(map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;} template <class T, class V> void print(unordered_map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;} /////////////////////de///////////////////// int a[1000006]; vi v[31][2]; int main() { fastio; int n; cin >> n; fra(n) fri(n) { frj(30) { if(a[i] & (1 << j)) { v[j][1].pb(a[i] % (1 << j)); } else v[j][0].pb(a[i] % (1 << j)); } } frj(30) { sort(all(v[j][0])); sort(all(v[j][1])); } ll ans = 0; frj(30) { ll cur = 0; ll pow = 1<<j; frp(2) { int id = v[j][1-p].size(); fri(v[j][p].size()) { while(id > 0 && pow - v[j][p][i] <= v[j][1-p][id-1]) //gtnel 1in >= y id--; cur += id; //tars nshan unecoxneri mej man gal poqreri tivy } id = v[j][p].size(); fri(v[j][p].size()) { while(id > 0 && pow - v[j][p][i] <= v[j][p][id-1]) //gtnel 1in >= y id--; cur += v[j][p].size()-id; //>= tivy if(v[j][p][i] >= pow - v[j][p][i]) cur--; } } // fri(n) { // int mod = a[i] % (1 << j); // if(a[i] & (1 << j)) { //v[j][0] ic petqa gtnel poqr % unecoxnery, 1y >= // auto it = lb(all(v[j][0]), (1 << j) - mod) - v[j][0].begin(); // cur += it; // it = lb(all(v[j][1]), (1 << j) - mod) - v[j][1].begin(); // cur += v[j][1].size()-it; // if(mod >= (1 << j) - mod) // cur--; //sa el einq hashvel // } else { // auto it = lb(all(v[j][1]), (1 << j) - mod) - v[j][1].begin(); // cur += it; // it = lb(all(v[j][0]), (1 << j) - mod) - v[j][0].begin(); // cur += v[j][0].size()-it; // if(mod >= (1 << j) - mod) // cur--; //sa el einq hashvel // } // } cur /= 2; fri(n) if((2 * a[i]) & pow) cur++; if(cur & 1) ans += pow; } cout << ans; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

xorsum.cpp: In function 'int main()':
xorsum.cpp:56:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 | #define fri(x) for(int i = 0; i < x; ++i)
      |                               ~~^~~~~~~~~
   57 | #define frj(x) for(int j = 0; j < x; ++j)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   58 | #define frp(x) for(int p = 0; p < x; ++p)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   59 | #define frr(a, b) for(int i = a; i < b; ++i)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   60 | #define frrj(a, b) for(int j = a; j < b; ++j)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   61 | #define fra(x) for(int i = 0; i < x; ++i) cin >> a[i];
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   62 | #define frb(x) for(int i = 0; i < x; ++i) cin >> b[i];
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   63 | #define frs(x) for(auto it = x.begin(); it != x.end(); ++it)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   64 | #define fr(x) for(auto it : x) //el
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   65 | #define fastio ios_base::sync_with_stdio(false); cin.tie(0);
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   66 | #define dbg(x) cerr << #x << ": " << x << endl;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   67 | #define ce(x) cout << x << endl;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   68 | #define uniq(x) x.resize(unique(all(x)) - x.begin()); //make all one after sorting
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 | #define blt __builtin_popcount
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
   70 | /////////////////////print array, vector, deque, set, multiset, pair, map /////////////////////
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   71 | void print(long long t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   72 | void print(int t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
   73 | void print(string t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   74 | void print(char t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
   75 | void print(double t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   76 | void print(long double t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   77 | void print(unsigned long long t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   78 | template <class T, class V> void print(pair <T, V> p) {cerr << "{"; print(p.first); cerr << ","; print(p.second); cerr << "}";}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   79 | template <class T, class V> void print(T v[],V n) {cerr << "["; for(int i = 0; i < n; i++) {print(v[i]); cerr << " "; } cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   80 | template <class T> void print(vector <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   81 | template <class T> void print(set <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   82 | template <class T> void print(multiset <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   83 | template <class T> void print(stack <T> v) {cerr << "[ "; stack<T> s = v; while(s.size()) {T i = s.top(); print(i); s.pop(); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   84 | template <class T> void print(queue <T> v) {cerr << "[ "; queue<T> s = v; while(s.size()) {T i = s.front(); print(i); s.pop(); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   85 | template <class T> void print(deque <T> v) {cerr << "[ "; deque<T> s = v; while(s.size()) {T i = s.front(); print(i); s.pop_front(); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   86 | template <class T, class V> void print(map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   87 | template <class T, class V> void print(unordered_map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   88 | /////////////////////de/////////////////////
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   89 | int a[1000006];
      | ~~~~~~~~~~~~~~~                  
   90 | vi v[31][2];
      | ~~~~~~~~~~~~                     
   91 | int main() {
      | ~~~~~~~~~~~~                     
   92 |     fastio;
      |     ~~~~~~~                      
   93 |     int n; cin >> n; fra(n)
      |     ~~~~~~~~~~~~~~~~~~~~~~~      
   94 |     fri(n) {
      |     ~~~~~~~~                     
   95 |         frj(30) {
      |         ~~~~~~~~~                
   96 |             if(a[i] & (1 << j)) {
      |             ~~~~~~~~~~~~~~~~~~~~~
   97 |                 v[j][1].pb(a[i] % (1 << j));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   98 |             } else v[j][0].pb(a[i] % (1 << j));
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   99 |         }
      |         ~                        
  100 |     }
      |     ~                            
  101 |     frj(30) {
      |     ~~~~~~~~~                    
  102 |         sort(all(v[j][0]));
      |         ~~~~~~~~~~~~~~~~~~~      
  103 |         sort(all(v[j][1]));
      |         ~~~~~~~~~~~~~~~~~~~      
  104 |     }
      |     ~                            
  105 |     ll ans = 0;
      |     ~~~~~~~~~~~                  
  106 |     frj(30) {
      |     ~~~~~~~~~                    
  107 |         ll cur = 0; ll pow = 1<<j;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~
  108 |         frp(2) {
      |         ~~~~~~~~                 
  109 |             int id = v[j][1-p].size();
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~
  110 |             fri(v[j][p].size()) {
      |             ~~~~~~~~~~~~~~~~~~   
xorsum.cpp:110:13: note: in expansion of macro 'fri'
  110 |             fri(v[j][p].size()) {
      |             ^~~
xorsum.cpp:56:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 | #define fri(x) for(int i = 0; i < x; ++i)
      |                               ~~^~~~~~~~~
   57 | #define frj(x) for(int j = 0; j < x; ++j)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   58 | #define frp(x) for(int p = 0; p < x; ++p)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   59 | #define frr(a, b) for(int i = a; i < b; ++i)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   60 | #define frrj(a, b) for(int j = a; j < b; ++j)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   61 | #define fra(x) for(int i = 0; i < x; ++i) cin >> a[i];
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   62 | #define frb(x) for(int i = 0; i < x; ++i) cin >> b[i];
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   63 | #define frs(x) for(auto it = x.begin(); it != x.end(); ++it)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   64 | #define fr(x) for(auto it : x) //el
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   65 | #define fastio ios_base::sync_with_stdio(false); cin.tie(0);
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   66 | #define dbg(x) cerr << #x << ": " << x << endl;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   67 | #define ce(x) cout << x << endl;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   68 | #define uniq(x) x.resize(unique(all(x)) - x.begin()); //make all one after sorting
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 | #define blt __builtin_popcount
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
   70 | /////////////////////print array, vector, deque, set, multiset, pair, map /////////////////////
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   71 | void print(long long t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   72 | void print(int t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
   73 | void print(string t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   74 | void print(char t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
   75 | void print(double t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   76 | void print(long double t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   77 | void print(unsigned long long t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   78 | template <class T, class V> void print(pair <T, V> p) {cerr << "{"; print(p.first); cerr << ","; print(p.second); cerr << "}";}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   79 | template <class T, class V> void print(T v[],V n) {cerr << "["; for(int i = 0; i < n; i++) {print(v[i]); cerr << " "; } cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   80 | template <class T> void print(vector <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   81 | template <class T> void print(set <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   82 | template <class T> void print(multiset <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   83 | template <class T> void print(stack <T> v) {cerr << "[ "; stack<T> s = v; while(s.size()) {T i = s.top(); print(i); s.pop(); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   84 | template <class T> void print(queue <T> v) {cerr << "[ "; queue<T> s = v; while(s.size()) {T i = s.front(); print(i); s.pop(); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   85 | template <class T> void print(deque <T> v) {cerr << "[ "; deque<T> s = v; while(s.size()) {T i = s.front(); print(i); s.pop_front(); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   86 | template <class T, class V> void print(map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   87 | template <class T, class V> void print(unordered_map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   88 | /////////////////////de/////////////////////
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   89 | int a[1000006];
      | ~~~~~~~~~~~~~~~                  
   90 | vi v[31][2];
      | ~~~~~~~~~~~~                     
   91 | int main() {
      | ~~~~~~~~~~~~                     
   92 |     fastio;
      |     ~~~~~~~                      
   93 |     int n; cin >> n; fra(n)
      |     ~~~~~~~~~~~~~~~~~~~~~~~      
   94 |     fri(n) {
      |     ~~~~~~~~                     
   95 |         frj(30) {
      |         ~~~~~~~~~                
   96 |             if(a[i] & (1 << j)) {
      |             ~~~~~~~~~~~~~~~~~~~~~
   97 |                 v[j][1].pb(a[i] % (1 << j));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   98 |             } else v[j][0].pb(a[i] % (1 << j));
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   99 |         }
      |         ~                        
  100 |     }
      |     ~                            
  101 |     frj(30) {
      |     ~~~~~~~~~                    
  102 |         sort(all(v[j][0]));
      |         ~~~~~~~~~~~~~~~~~~~      
  103 |         sort(all(v[j][1]));
      |         ~~~~~~~~~~~~~~~~~~~      
  104 |     }
      |     ~                            
  105 |     ll ans = 0;
      |     ~~~~~~~~~~~                  
  106 |     frj(30) {
      |     ~~~~~~~~~                    
  107 |         ll cur = 0; ll pow = 1<<j;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~
  108 |         frp(2) {
      |         ~~~~~~~~                 
  109 |             int id = v[j][1-p].size();
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~
  110 |             fri(v[j][p].size()) {
      |             ~~~~~~~~~~~~~~~~~~~~~
  111 |                 while(id > 0 && pow - v[j][p][i] <= v[j][1-p][id-1]) //gtnel 1in >= y
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  112 |                     id--;
      |                     ~~~~~        
  113 |                 cur += id; //tars nshan unecoxneri mej man gal poqreri tivy
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  114 |             }
      |             ~                    
  115 |             id = v[j][p].size();
      |             ~~~~~~~~~~~~~~~~~~~~ 
  116 |             fri(v[j][p].size()) {
      |             ~~~~~~~~~~~~~~~~~~   
xorsum.cpp:116:13: note: in expansion of macro 'fri'
  116 |             fri(v[j][p].size()) {
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...