QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#828396 | #4283. Power of XOR | Invincible | WA | 1ms | 3892kb | C++23 | 2.0kb | 2024-12-23 16:27:47 | 2024-12-23 16:27:50 |
Judging History
answer
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <ctime>
#include <random>
#include <cassert>
#include <numeric>
#include <cmath>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#define pii pair<int, int>
#define fi first
#define se second
#define MP make_pair
#define ep emplace
#define eb emplace_back
#define int long long
#define rep(i, j, k) for (int i = (j); i <= (k); i++)
#define per(i, j, k) for (int i = (j); i >= (k); i--)
typedef double db;
typedef long double ldb;
typedef long long ll;
//typedef __int128 lll;
typedef unsigned long long ull;
typedef unsigned int ui;
using namespace std;
using namespace __gnu_pbds;
bool Mbe;
//char buf[1<<20],*p1,*p2;
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin), p1 == p2) ? 0 : *p1++)
int read() {
int s = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') f ^= (c == '-'), c = getchar();
while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();
return f ? s : -s;
}
template<typename T>void chkmax(T&x,const T&y){if(x<y)x=y;}
template<typename T>void chkmin(T&x,const T&y){if(x>y)x=y;}
const int mod=1e9+7;
int fpow(int x,int k){
int res=1;
for(;k;k>>=1){
if(k&1)res=res*x%mod;
x=x*x%mod;
}
return res;
}
int n,k,a[45],val[1<<24],pw[45],b[45],ans;
int w1[45];
bool insert(int x){
per(i,43,0){
if(x>>i&1){
if(!w1[i])return w1[i]=x,1;
x^=w1[i];
}
}
return 0;
}
bool Med;
signed main() {
fprintf(stderr,"%.3lfMb\n",(&Mbe-&Med)/1024./1024.);
n=read(),k=read();
int cnt=0;
rep(i,0,44)pw[i]=fpow(i,k);
rep(i,0,n-1){
if(insert(a[i]=read())){
b[cnt++]=i;
}
}
if(cnt<=24){
rep(S,1,(1<<cnt)-1){
val[S]=val[S^(S&-S)]^a[b[__lg(S&-S)]];
ans=(ans+pw[__builtin_popcount(val[S])])%mod;
}
ans=ans*fpow(2,n-cnt)%mod;
}else{
}
printf("%lld\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3740kb
input:
3 2 1 2 3
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
2 1000000000 1 2
output:
140625003
result:
ok 1 number(s): "140625003"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
3 4 21 31 15
output:
1076
result:
ok 1 number(s): "1076"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
4 10 21 16 23 30
output:
3504120
result:
ok 1 number(s): "3504120"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3732kb
input:
5 795325759 23 18 18 15 24
output:
398580583
result:
ok 1 number(s): "398580583"
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3892kb
input:
6 425010546 15190825693299 11021868218180 10853490476696 16489831131502 15731786397897 1859285400474
output:
899135263
result:
wrong answer 1st numbers differ - expected: '226806798', found: '899135263'