Submission #496885

# Submission time Handle Problem Language Result Execution time Memory
496885 2021-12-22T06:03:58 Z Ziel XOR Sum (info1cup17_xorsum) C++17
Compilation error
0 ms 0 KB
/**
 * LES GREATEABLES BRO TEAM
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
#define sz(x) (int)x.size()
const bool FLAG = false;
void setIO(const string &f = "");

#define int ll

void solve() {
    int n;
    cin >> n;
    vector<int> ar(n);
    int mx = 0, res = 0;
    for (int &x: ar) {
    	cin >> x;
    	mx = max(mx, x);
    }

    /*if (n * n <= 1e8) {
    	for (int i = 0; i < n; i++) {
    		for (int j = i; j < n; j++) {
    			res ^= (a[i] + a[j]);
    		}
    	}
    } else if (mx * mx <= 4e8) {*/
    	ordered_set<int> occ[mx + 5];
    	for (int i = 0; i < n; i++) {
    		occ[ar[i]].insert(i);
    	}
    	vector<int> v(mx + mx + 5);
    	for (int a = 1; a <= mx; a++) {
    		if (!sz(occ[a]))
    			continue;
    		for (int b = 1; b <= mx; b++) {
    			if (!sz(occ[b]))
    				continue;
    			for (int pos: occ[a]) {
    				int k = sz(occ[b]) - occ[b].order_of_key(pos);
					v[a + b] += k;
    			}
    		}
    	}
    	for (int i = 1; i <= mx + mx; i++)
    		res ^= ((v[i] % 2) * i;)
    //}

	cout << res;
}

signed main() {
    setIO();
    
    int tt = 1;
    if (FLAG) {
    	cin >> tt;
    }
    while (tt--) {
    	solve();
    }
    
    return 0;
}

void setIO(const string &f) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if (fopen((f + ".in").c_str(), "r")) {
        freopen((f + ".in").c_str(), "r", stdin);
        freopen((f + ".out").c_str(), "w", stdout);
    }
}

Compilation message

xorsum.cpp: In function 'void solve()':
xorsum.cpp:55:29: error: expected ')' before ';' token
   55 |       res ^= ((v[i] % 2) * i;)
      |              ~              ^
      |                             )
xorsum.cpp:54:6: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   54 |      for (int i = 1; i <= mx + mx; i++)
      |      ^~~
xorsum.cpp:55:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   55 |       res ^= ((v[i] % 2) * i;)
      |                              ^
xorsum.cpp:55:30: error: expected primary-expression before ')' token
xorsum.cpp: In function 'void setIO(const string&)':
xorsum.cpp:79:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |         freopen((f + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xorsum.cpp:80:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |         freopen((f + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~