이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
template<typename TH>
void _dbg(const char* sdbg, TH h)
{
cerr << sdbg << " = " << h << "\n";
}
template<typename TH, typename... TA>
void _dbg(const char* sdbg, TH h, TA... t)
{
while (*sdbg != ',') cerr << *sdbg++;
cerr << " = " << h << ",";
_dbg(sdbg + 1, t...);
}
#define db(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define chkpt cerr << "--- Checkpoint here ---\n";
const int N=1e6+6;
int n;
int64_t a[N];
void Sub1(){
int ans=0;
for(int i=1;i<=n;++i){
for(int j=i;j<=n;++j){
ans^=(a[i]+a[j]);
}
}
cout<<ans;
}
int Check(int pos){
int res=0;
vector<vector<int>> vec(2);
for(int i=n;i>=1;--i){
int64_t val=0;
for(int j=0;j<pos;++j){
if((a[i]>>j)&1){
val|=1<<j;
}
}
if((a[i]>>pos)&1){
vec[1].push_back(val);
int cnt=0;
for(int j=0;j<vec[0].size();++j){
if(vec[0][j]+val<(1<<pos)){
cnt++;
}
}
res^=(cnt%2);
cnt=0;
for(int j=0;j<vec[1].size();++j){
if(vec[1][j]+val>=(1<<pos)){
cnt++;
}
}
res^=(cnt%2);
}
else{
vec[0].push_back(val);
int cnt=0;
for(int j=0;j<vec[1].size();++j){
if(vec[1][j]+val<(1<<pos)){
cnt++;
}
}
res^=(cnt%2);
cnt=0;
for(int j=0;j<vec[0].size();++j){
if(vec[0][j]+val>=(1<<pos)){
cnt++;
}
}
res^=(cnt%2);
}
}
return res;
}
void Sub2(){
int64_t ans=0;
for(int i=0;i<=31;++i){
if(Check(i)){
ans+=(int64_t)1<<i;
}
}
cout<<ans;
}
int main()
{
// freopen("info1cup17_xorsum.inp","r",stdin);
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n;
for(int i=1;i<=n;++i){
cin>>a[i];
}
Sub2();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
xorsum.cpp: In function 'int Check(int)':
xorsum.cpp:50:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<vec[0].size();++j){
~^~~~~~~~~~~~~~
xorsum.cpp:57:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<vec[1].size();++j){
~^~~~~~~~~~~~~~
xorsum.cpp:67:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<vec[1].size();++j){
~^~~~~~~~~~~~~~
xorsum.cpp:74:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<vec[0].size();++j){
~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |