답안 #67971

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67971 2018-08-15T16:11:49 Z hamzqq9 XOR Sum (info1cup17_xorsum) C++14
0 / 100
18 ms 736 KB
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1ll<<(x))
#define inf 1000000000000000000
#define MOD 1000000007
#define N 2005
#define MAX 10000006
#define LOG 30
using namespace std;

int n,ans,a[N];
vector<ii> v;

int main() {

//	freopen("input.txt","r",stdin);

	scanf("%d",&n);

	for(int i=1;i<=n;i++) {

		scanf("%d",&a[i]);

		v.pb({a[i]&1,i});

	}

	sort(all(v));

	for(int i=0;i<LOG;i++) {

		int bas=n,son=n-1;

		int ok=0;

		for(int j=0;j<n;j++) {

			umax(bas,j);

			while(son>=0 && v[son].st+v[j].st>pw(i+1)-1) son--;
			while(bas-1>=0 && v[bas-1].st+v[j].st>=pw(i)) bas--;

			ok^=max(0,(son-bas+1))&1;

		}

		bas=n,son=n-1;

		for(int j=0;j<n;j++) {

			umax(bas,j);

			while(son>=0 && v[son].st+v[j].st>pw(i+2)-2) son--;
			while(bas-1>=0 && v[bas-1].st+v[j].st>=pw(i+1)+pw(i)) bas--;

			ok^=max(0,(son-bas+1))&1;

		}

		if(ok) ans+=pw(i);

		vector<ii> v2;

		for(int j=0;j<n;j++) if(!(a[v[j].nd]&pw(i+1))) v2.pb(v[j]);

		for(int j=0;j<n;j++) if(a[v[j].nd]&pw(i+1)) v2.pb({v[j].st+pw(i+1),v[j].nd});

		v=v2;

	}

	printf("%d",ans);

}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
xorsum.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 736 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 736 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -