TÓPICO
Presentation error (5%)
migrmez perguntou 2 years ago
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void print(ll y) {
printf("%lld ", y);
}
void solve(vector<ll> &x, int cero) {
ll result = 0LL;
int band = true;
for (int i = 0; i < (int) x.size(); ++i) {
result ^= (ll) x[i];
if (x[i] == 0 && (cero % 2 == 1) && band) {
print(x[i]);
band = false;
}
if (x[i] == 0 && !band) {
continue;
}
if (result != 0 && x[i] != x[i + 1]) {
print(x[i]);
result = 0LL;
}
}
printf("\n");
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
while (scanf("%d", &n) != EOF) {
if (n == 0) {
break;
}
int c = 0;
vector<ll> p(n);
for (int i = 0; i < n; ++i) {
scanf("%lld", &p[i]);
if (p[i] == 0) {
c++;
}
}
sort(p.begin(), p.end());
solve(p, c);
}
return 0;
}
Este tópico ainda não foi respondido. Seja o primeiro!