Submission #30246718
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i=a; i<=b; i++)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define f first
#define s second
#define nl "\n"
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int N=1000001;
int n,m;
int a[N];
int A[N];
vi solve(int i, int k){
vi ret(1<<k);
if(i<=0) return ret;
if(k==0){
ret[0]=a[i];
return ret;
}
vi a=solve(i, k-1);
vi b=solve(i-(1<<(k-1)), k-1);
rep(j,0,(1<<(k-1))-1){
ret[j]=a[j]^b[j];
}
rep(j,0,(1<<(k-1))-1){
ret[j+(1<<(k-1))]=(a[j]);
}
// cout << i << " " << k << nl;
// for(int x:ret) cout << x << " ";
// cout << nl;
return ret;
}
int main(){
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m;
rep(i,1,n){
cin >> a[i];
A[i]=A[i-1]^a[i];
}
int k=0;
while((1<<k)<max(n,m)) k++;
vi ret=solve(n, k);
rep(i,0,m-1) cout << ret[i] << " ";
}
// mex?
// "moving" A a_1 a_2...a_n -> 0 1...n
Submission Info
| Submission Time | |
|---|---|
| Task | D - Prefix XORs |
| User | czhang2718 |
| Language | C++ (GCC 9.2.1) |
| Score | 700 |
| Code Size | 1083 Byte |
| Status | AC |
| Exec Time | 303 ms |
| Memory | 23676 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 700 / 700 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-001.txt, 00-sample-002.txt |
| All | 00-sample-001.txt, 00-sample-002.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-001.txt | AC | 8 ms | 3500 KiB |
| 00-sample-002.txt | AC | 2 ms | 3524 KiB |
| 01-001.txt | AC | 2 ms | 3500 KiB |
| 01-002.txt | AC | 58 ms | 10892 KiB |
| 01-003.txt | AC | 61 ms | 11496 KiB |
| 01-004.txt | AC | 145 ms | 20728 KiB |
| 01-005.txt | AC | 144 ms | 20620 KiB |
| 01-006.txt | AC | 252 ms | 21464 KiB |
| 01-007.txt | AC | 56 ms | 8568 KiB |
| 01-008.txt | AC | 139 ms | 22020 KiB |
| 01-009.txt | AC | 215 ms | 23676 KiB |
| 01-010.txt | AC | 269 ms | 23596 KiB |
| 01-011.txt | AC | 290 ms | 23596 KiB |
| 01-012.txt | AC | 303 ms | 23664 KiB |
| 01-013.txt | AC | 216 ms | 23600 KiB |