답안 #348988

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
348988 2021-01-16T09:30:58 Z RohamIzadidoost XOR Sum (info1cup17_xorsum) C++14
56 / 100
1600 ms 4332 KB
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define pll pair<ll , ll >
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)(x).size()
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
const int maxn = 1000*1000+5 ;
const int maxm = 4e3 + 3 ; 
const ll inf = 9223372036854775807 ;
const ll mod = 1e9 + 7 ;
int n  , v[maxn] , ans , a[maxn] , s2  = 1; 
int main()
{
	migmig ;
	cin>>n ; 
	for(int i =1 ; i <= n ; i ++ ){
		cin>>v[i] ; 
		if(v[i] > maxm) s2 = 0 ; 
	} 
	if(!s2){
		for(int i = 1 ; i <= n ; i ++ ){
			for(int j = i ; j <= n ; j++ ){
				ans = ans ^ (v[i] + v[j]) ; 
			}
		}
		cout<<ans ; 
		return 0 ; 
	}
	for(int i = 1 ; i <= n; i ++ ) a[v[i]] ++  ; 
	register int i , j ;
	for(i = 1 ; i < maxm ; i ++ ){
		for(j = 1 ; j < i ; j ++ ){
			ans = ans ^ (  ( (a[i] * a[j] ) & 1 ) * (i + j) ) ;
			//if((  ( (a[i] * a[j] ) & 1 ) * (i + j) )) cout<<(  ( (a[i] * a[j] ) & 1 ) * (i + j) ) << endl ;  
		}
		ans = ans ^ ( ( (a[i] * (a[i] + 1) / 2) & 1 ) * 2 * i ) ; 
	}
	cout<<ans ; 
}








# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 4332 KB Output is correct
2 Correct 91 ms 3948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 4332 KB Output is correct
2 Correct 91 ms 3948 KB Output is correct
3 Execution timed out 1667 ms 4204 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 553 ms 800 KB Output is correct
4 Correct 555 ms 876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 96 ms 4332 KB Output is correct
4 Correct 91 ms 3948 KB Output is correct
5 Execution timed out 1667 ms 4204 KB Time limit exceeded
6 Halted 0 ms 0 KB -