Submission #522865

# Submission time Handle Problem Language Result Execution time Memory
522865 2022-02-06T07:40:49 Z n3rm1n XOR Sum (info1cup17_xorsum) C++17
0 / 100
10 ms 460 KB
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
const int MAXN = 4 * 1e3 + 10;
void speed()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
int n, a[MAXN];
int used[MAXN];
int ans;
void read()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i)
    {
        cin >> a[i];
        used[a[i]] ++;
    }
}
void solve_N2()
{
    for (int i = 1; i <= n; ++ i)
    {
        for (int j = i; j <= n; ++ j)
        {
            ans = (ans ^ (a[i]+a[j]));
        }
    }
    cout << ans << endl;
}
void solve_11()
{
    for (int i = 0; i <= 4*1e3; ++ i)
    {
        if(used[i])
        {
            //ans = ans *
            if(used[i] %2 == 0 || used[i] == 1)
                ans = ans ^ (i + i);
            for (int j = i+1; j <= 4*1e3; ++ j)
            {
                if(used[j])
                {
                    /**cout << "/***" << endl;
                    cout << i << " " << j << endl;
                    cout << used[i] << " " << used[j] << endl;
                    cout << i + j << endl;*/
                    if(used[j] %2 == 0 || used[i] %2 == 0) ans = ans;
                        else
                    {
                        ans = ans ^ (i + j);
                        ///cout << "xor: " << i + j << endl;
                    }

                }
            }

        }
    }
    cout << ans << endl;
}
int main()
{
	speed();
	read();
	/*if(n <= MAXN)solve_N2();
	else*/ solve_11();
	return 0;
}

Compilation message

xorsum.cpp:48:33: warning: "/*" within comment [-Wcomment]
   48 |                     /**cout << "/***" << endl;
      |
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -