Contest Duration: - (local time) (300 minutes) Back to Home

Submission #7225833

Source Code Expand

Copy
```#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
∧＿∧
∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
（ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
／　　　＼　 　  |　|
/　　 /￣￣￣￣/　　|
＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N, X, A[501010];
//---------------------------------------------------------------------------------------------------
bool solve() {
int xo = X;
int cnt = 0;
rep(i, 0, N) {
if (A[i] < 0) cnt++;
else xo ^= A[i];
}

if (cnt == 0) {
if (xo == 0) return true;
else return false;
} else if (cnt == 1) {
if (0 <= xo and xo <= X) {
rep(i, 0, N) if(A[i] < 0) A[i] = xo;
return true;
}
else return false;
} else {
int ans1 = 1;
while(ans1 < xo) ans1 *= 2;
ans1 /= 2;
int ans2 = xo - ans1;

int flag = 0;
rep(i, 0, N) if(A[i] < 0) {
if(flag == 0) A[i] = ans1, flag++;
else if(flag == 1) A[i] = ans2, flag++;
else A[i] = 0;
}

if (ans1 <= X and ans2 <= X) return true;
else return false;
}
}
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> N >> X;
rep(i, 0, N) cin >> A[i];

auto ans = solve();

if (ans) {
rep(i, 0, N) {
if(i) printf(" ");
printf("%d", A[i]);
}
printf("\n");
} else {
printf("-1\n");
}
}

```

#### Submission Info

Submission Time 2019-08-31 19:22:31+0900 C - XOR Filling hamayanhamayan C++14 (GCC 5.4.1) 100 2523 Byte AC 97 ms 7040 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
 AC × 3
 AC × 32
Set Name Test Cases
Sample 00_sample_01, 00_sample_02, 00_sample_03
All 00_sample_01, 00_sample_02, 00_sample_03, 01_small_01, 01_small_02, 01_small_03, 02_large_01, 02_large_02, 02_large_03, 02_large_04, 03_corner_01, 03_corner_02, 03_corner_03, 03_corner_04, 03_corner_05, 03_corner_06, 03_corner_07, 04_random_01, 04_random_02, 04_random_03, 04_random_04, 04_random_05, 05_random_01, 05_random_02, 05_random_03, 05_random_04, 05_random_05, 05_random_06, 05_random_07, 05_random_08, 05_random_09, 05_random_10
Case Name Status Exec Time Memory
00_sample_01 AC 1 ms 256 KB
00_sample_02 AC 1 ms 256 KB
00_sample_03 AC 1 ms 256 KB
01_small_01 AC 1 ms 256 KB
01_small_02 AC 1 ms 256 KB
01_small_03 AC 1 ms 256 KB
02_large_01 AC 50 ms 2176 KB
02_large_02 AC 97 ms 7040 KB
02_large_03 AC 95 ms 5760 KB
02_large_04 AC 73 ms 3200 KB
03_corner_01 AC 1 ms 256 KB
03_corner_02 AC 1 ms 256 KB
03_corner_03 AC 1 ms 256 KB
03_corner_04 AC 1 ms 256 KB
03_corner_05 AC 1 ms 256 KB
03_corner_06 AC 1 ms 256 KB
03_corner_07 AC 1 ms 256 KB
04_random_01 AC 50 ms 3072 KB
04_random_02 AC 12 ms 896 KB
04_random_03 AC 44 ms 2688 KB
04_random_04 AC 62 ms 3840 KB
04_random_05 AC 5 ms 512 KB
05_random_01 AC 52 ms 3840 KB
05_random_02 AC 21 ms 1024 KB
05_random_03 AC 10 ms 896 KB
05_random_04 AC 5 ms 384 KB
05_random_05 AC 21 ms 1024 KB
05_random_06 AC 36 ms 1664 KB
05_random_07 AC 45 ms 3328 KB
05_random_08 AC 3 ms 384 KB
05_random_09 AC 75 ms 5504 KB
05_random_10 AC 86 ms 6272 KB