#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define sz size()
#define fil(arr,x) memset(arr,x,sizeof(arr))
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
cout<<(x?"YES":"NO")<<endl;
}
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
int n;cin>>n;
vector<int>arr(n);
for(auto &i:arr)cin>>i;
int ans=0;
map<int,int>fr;
for(int i=0;i<n;i++){
++fr[arr[i]];
}
vector<int>v;
set<int>s;
map<int,int>vis;
for(int i=0;i<n;i++){
if(fr[arr[i]]&1)s.insert(arr[i]);
if(vis[arr[i]])continue;
vis[arr[i]]=1;
ll k=(fr[arr[i]]*(fr[arr[i]]+1))/2;
if(k&1)ans^=(arr[i]*2);
}
for(auto i:s)v.pb(i);
for(int i=0;i<v.sz;i++){
for(int j=i+1;j<v.sz;j++){
ans^=(v[i]+v[j]);
}
}
cout<<ans<<endl;
return 0;
}
Compilation message
xorsum.cpp: In function 'int main()':
xorsum.cpp:59:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | for(int i=0;i<v.sz;i++){
| ^
xorsum.cpp:60:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | for(int j=i+1;j<v.sz;j++){
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
852 KB |
Output is correct |
2 |
Correct |
7 ms |
852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
376 ms |
4696 KB |
Output is correct |
2 |
Correct |
348 ms |
4400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
376 ms |
4696 KB |
Output is correct |
2 |
Correct |
348 ms |
4400 KB |
Output is correct |
3 |
Execution timed out |
1670 ms |
58440 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
852 KB |
Output is correct |
2 |
Correct |
7 ms |
852 KB |
Output is correct |
3 |
Execution timed out |
1686 ms |
15400 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
852 KB |
Output is correct |
2 |
Correct |
7 ms |
852 KB |
Output is correct |
3 |
Correct |
376 ms |
4696 KB |
Output is correct |
4 |
Correct |
348 ms |
4400 KB |
Output is correct |
5 |
Execution timed out |
1670 ms |
58440 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |