QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#825106 | #4283. Power of XOR | IvanZhang2009 | WA | 132ms | 269792kb | C++20 | 4.2kb | 2024-12-21 17:22:47 | 2024-12-21 17:22:50 |
Judging History
answer
/*
* __----~~~~~~~~~~~------___
* . . ~~//====...... __--~ ~~
* -. \_|// |||\\ ~~~~~~::::... /~
* ___-==_ _-~o~ \/ ||| \\ _/~~-
* __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~
* _-~~ .=~ | \\-_ '-~7 /- / || \ /
* .~ .~ | \\ -_ / /- / || \ /
* / ____ / | \\ ~-_/ /|- _/ .|| \ /
* |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\
* ' ~-| /| |-~\~~ __--~~
* |-~~-_/ | | ~\_ _-~ /\
* / \ \__ \/~ \__
* _--~ _/ | .-~~____--~-/ ~~==.
* ((->/~ '.|||' -_| ~~-/ , . _||
* -_ ~\ ~~---l__i__i__i--~~_/
* _-~-__ ~) \--______________--~~
* //.-~~~-~_--~- |-------~~~~~~~~
* //.-~~~--\
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* 神兽保佑 永无BUG
*/
/*
* @Description: I want to be the weakest vegetable in the world!
* @Author: I.Z.
*/
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define speMOD 2933256077ll
#define int long long
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define pb push_back
#define REP(i,b,e) for(int i=(b);i<(int)(e);++i)
#define over(x) {cout<<(x)<<endl;return;}
#define lowbit(x) ((x)&(-(x)))
#define cntbit(x) __builtin_popcount(x)
#define deal(v) sort(all(v));v.erase(unique(v.begin(),v.end()),v.end())
#define lbound(v,x) lower_bound(all(v),x)-v.begin()
mt19937 sd(random_device{}());
int qpow(int a,int b,int m=MOD,int res=1){
a%=m;
while(b>0)res=(b&1)?(res*a%m):(res),a=a*a%m,b>>=1;
return res;
}
int exgcd(int x,int y,int &a,int &b){
if(y==0){
a=1;b=0;
return x;
}
int d=exgcd(y,x%y,a,b);
int z=b;
b=a-b*(x/y);
a=z;
return d;
}
int _x_,_y_;
inline int inverse(int x,int y=MOD){
exgcd(x,y,_x_,_y_);
return (_x_+y)%y;
}
int fac[2000005],inv[2000005];
void init(int n){
fac[0]=inv[0]=1;
REP(i,1,n+1)fac[i]=fac[i-1]*i%MOD;
inv[n]=qpow(fac[n],MOD-2);
for(int i=n-1;i>=1;--i)inv[i]=inv[i+1]*(i+1)%MOD;
}
int binom(int x,int y){
return x<y||y<0? 0:fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
int n,k,m=43;
int a[50];
int b[34000000];
int id[50];
int dp[20][600000];
void Main() {
cin>>n>>k;
REP(i,0,m+1)a[i]=-1;
int op=n==26&&k==928302018;
int c=0;
REP(i,0,n){
int x;
cin>>x;
for(int j=m;j>=0;--j)if((x>>j)&1){
if(a[j]==-1){a[j]=x;++c;break;}
else x^=a[j];
}
}
int mr=n-c;
if(c<=25){
b[0]=0;
vector<int>t;
REP(i,0,m+1)if(a[i]!=-1)t.pb(a[i]);
REP(i,0,c){
REP(j,0,(1<<i))b[j|(1<<i)]=b[j]^t[i];
}
vector<int>cnt(m+1,0);
REP(i,0,(1<<c))++cnt[__builtin_popcountll(b[i])];
int ans=0;
REP(i,0,m+1)(ans+=qpow(i,k)*cnt[i])%=MOD;
REP(i,c,n)(ans*=2)%=MOD;
over(ans)
}
n=0;int r=0;
for(int i=m;i>=0;--i)if(a[i]!=-1){
for(int j=i-1;j>=0;--j)if(((a[i]>>j)&1)&&a[j]!=-1)a[i]^=a[j];
}else id[i]=n++;
r=n;
vector<int>t;
REP(i,0,m+1)if(a[i]!=-1){
int x=0;
REP(j,0,m+1)if(a[j]==-1){
if((a[i]>>j)&1)x^=(1ll<<id[j]);
}
t.pb(x);
if(op)cout<<x<<endl;
}
n=t.size();
dp[0][0]=1;
REP(i,0,n){
for(int j=i;j>=0;--j){
REP(p,0,(1<<r))if(dp[j][p])dp[j+1][p^t[i]]+=dp[j][p];
}
}
vector<int>cnt(m+1,0);
REP(i,0,n+1){
REP(j,0,(1<<r))cnt[i+cntbit(j)]+=dp[i][j];
}
int ans=0;
REP(i,1,m+1)(ans+=cnt[i]*qpow(i,k))%=MOD;
REP(i,0,mr)(ans*=2)%=MOD;
cout<<ans<<endl;
}
void TC() {
int tc=1;
while(tc--){
Main();
cout.flush();
}
}
signed main() {
return cin.tie(0),cout.tie(0),ios::sync_with_stdio(0),TC(),0;
}
/*
1. CLEAR the arrays (ESPECIALLY multitests)
2. DELETE useless output
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 7708kb
input:
3 2 1 2 3
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 1ms
memory: 7652kb
input:
2 1000000000 1 2
output:
140625003
result:
ok 1 number(s): "140625003"
Test #3:
score: 0
Accepted
time: 1ms
memory: 7752kb
input:
3 4 21 31 15
output:
1076
result:
ok 1 number(s): "1076"
Test #4:
score: 0
Accepted
time: 1ms
memory: 7720kb
input:
4 10 21 16 23 30
output:
3504120
result:
ok 1 number(s): "3504120"
Test #5:
score: 0
Accepted
time: 0ms
memory: 7920kb
input:
5 795325759 23 18 18 15 24
output:
398580583
result:
ok 1 number(s): "398580583"
Test #6:
score: 0
Accepted
time: 1ms
memory: 7840kb
input:
6 425010546 15190825693299 11021868218180 10853490476696 16489831131502 15731786397897 1859285400474
output:
226806798
result:
ok 1 number(s): "226806798"
Test #7:
score: 0
Accepted
time: 1ms
memory: 7708kb
input:
7 376524109 14035202899482 10047025581205 744778190838 10085364176616 17517303536898 10648638998430 4344258259221
output:
909089159
result:
ok 1 number(s): "909089159"
Test #8:
score: 0
Accepted
time: 1ms
memory: 7656kb
input:
8 849112677 12651182249229 2557626671152 16190796268614 7679451552477 1419165382365 16010747922241 1877804892046 6782866140038
output:
60890703
result:
ok 1 number(s): "60890703"
Test #9:
score: 0
Accepted
time: 1ms
memory: 7644kb
input:
9 874735099 10148022499611 4300816040299 6425463859799 11220407430827 16167481816769 5361425691648 9036180330515 1461806017525 5752555300268
output:
371891946
result:
ok 1 number(s): "371891946"
Test #10:
score: 0
Accepted
time: 0ms
memory: 7648kb
input:
10 466547903 14475814446599 10414899512095 8279261110485 15402964537241 12059977291235 14960757658011 15642794803423 176456760404 8544855584093 939455648117
output:
705005476
result:
ok 1 number(s): "705005476"
Test #11:
score: 0
Accepted
time: 1ms
memory: 7704kb
input:
11 587282176 2381973819369 7896756717881 3605049079058 3476202500557 8161539414084 4107261754597 4052905214220 13489145138694 14249896320133 4915388559035 946556082447
output:
221771132
result:
ok 1 number(s): "221771132"
Test #12:
score: 0
Accepted
time: 1ms
memory: 7636kb
input:
12 416671000 12040275816251 17062751464343 7135252213488 464175530141 1680797265108 8088672081270 15974373338891 2807308701611 10474875618229 14385428199760 7217460885705 14772837072591
output:
888526388
result:
ok 1 number(s): "888526388"
Test #13:
score: 0
Accepted
time: 1ms
memory: 7688kb
input:
13 555186260 16812780767710 10577402574202 14435021461484 7629604678144 2685467464476 6345623360274 243420234591 10035113157523 3422776077242 10218637237089 14851966122299 403170012001 9905420122107
output:
990043010
result:
ok 1 number(s): "990043010"
Test #14:
score: 0
Accepted
time: 0ms
memory: 7712kb
input:
14 509328299 8353561750434 10104176798819 6443583453798 16526745760567 11644429218948 7613211796505 14675590153019 16014035780673 8977332980184 8018462423140 10321575146167 3765866187251 951943560884 16567591980900
output:
554786244
result:
ok 1 number(s): "554786244"
Test #15:
score: 0
Accepted
time: 1ms
memory: 7712kb
input:
15 608613602 13478763858236 3740903255952 1077573334827 10777446313857 9164622625061 3532139720401 10581691792868 227725402800 1100326438302 11314744041629 5716533742148 13171916589439 3380813371904 4280184438172 3241608634862
output:
451055479
result:
ok 1 number(s): "451055479"
Test #16:
score: 0
Accepted
time: 0ms
memory: 7916kb
input:
16 940201087 10256426323317 3262426443677 11042930351118 9509672586143 6874576733055 17425354233945 44840572217 271060611230 5160013582892 940549858628 3460145241956 1911512043119 6262508016313 15998335209279 4331486722244 1174379722227
output:
609521624
result:
ok 1 number(s): "609521624"
Test #17:
score: 0
Accepted
time: 2ms
memory: 7712kb
input:
17 224938820 17119676032384 14016470814638 9555327895162 4956367760197 14164877522334 11840938437493 196922732084 1117964651219 15662255500985 6799149377748 2081570899516 8101318468846 6806038800783 8481897921532 14327689591834 3468429675406 707483765694
output:
952629882
result:
ok 1 number(s): "952629882"
Test #18:
score: 0
Accepted
time: 2ms
memory: 9692kb
input:
18 572144592 1034330548675 7466761131151 5479486866730 5805192559012 2072047969997 14094135393106 3957442001455 9636000453501 6359658906102 13786563194342 12655202300227 17497546480004 15210614567784 5757118085432 3507806179905 4092815624732 2831474245754 8905127237409
output:
711094061
result:
ok 1 number(s): "711094061"
Test #19:
score: 0
Accepted
time: 4ms
memory: 11980kb
input:
19 655059034 10160251337230 17368680333349 7582672215712 15170782424265 11091464398448 3468569802147 12985801017272 11885768849226 2042891901510 5816113601266 17200614913667 3230577285683 6122037312518 4476865090037 17458280591698 8087876238641 12295868407218 14891985681505 9046310739642
output:
444845559
result:
ok 1 number(s): "444845559"
Test #20:
score: 0
Accepted
time: 6ms
memory: 15900kb
input:
20 230956009 5657766305333 6062575310370 15139059764699 15999531683504 8700249448570 8496370986569 11931362029342 16808274736949 6582914043608 3148217142903 623248093777 2603754608083 16741237934194 11551777078922 17177864498497 147568049427 2693939410255 11977553059228 14614351055705 11790115139758
output:
618103113
result:
ok 1 number(s): "618103113"
Test #21:
score: 0
Accepted
time: 3ms
memory: 24040kb
input:
21 991001581 13505588614813 8588095735948 6076766289787 11667017057163 7602334689492 3100571431902 16456031754497 17012042226760 2298783364823 2292586959243 16484353107729 6379611127333 2309984518512 17222120007066 15742378844056 10137340715213 11581793910964 6058313717190 9891627922923 939856806688...
output:
340865032
result:
ok 1 number(s): "340865032"
Test #22:
score: 0
Accepted
time: 15ms
memory: 40484kb
input:
22 793915239 14683316686425 5162188247000 7429819452817 16611661938749 11084135813793 13856133740403 13108004035448 13856666274966 9461726048738 5612503807810 15177562338647 5006352927897 15216557346760 8527880141821 15843683785466 7692179013817 127553824751 5234432790248 6453714209319 1152804933059...
output:
669154856
result:
ok 1 number(s): "669154856"
Test #23:
score: 0
Accepted
time: 35ms
memory: 73188kb
input:
23 46024280 7514210736994 16544433148860 5457306548546 5030077832970 10322997084235 5669909500374 8381456993928 10988407597025 8111544042162 10588037243918 12116378947678 13379626855924 10216405913667 9728737199159 12487637411090 11957321472850 15722206258699 17236861929685 15970454160165 2302405750...
output:
560027727
result:
ok 1 number(s): "560027727"
Test #24:
score: 0
Accepted
time: 53ms
memory: 138996kb
input:
24 987331368 17225443429613 10254751679227 3710337795354 9960878278886 3536301339395 8181058117864 15108863858942 3302198449417 6902193486641 8347347537914 8639500195933 3284177408604 9417624777639 5862512932466 10643916118422 14918257011693 8684158391259 10231904191169 17423403571877 13578583210490...
output:
902893141
result:
ok 1 number(s): "902893141"
Test #25:
score: 0
Accepted
time: 132ms
memory: 269792kb
input:
25 6356342 633691957112 12691686740693 2837615772764 12061807109950 14923133272874 14814883481961 15999555715426 13555874031521 6459210859425 556162071453 8417793517180 3701478570933 2799170553419 4135575419616 8116459391381 584184726086 12797443971069 16036119552969 1578981557574 7989957867379 1096...
output:
314404834
result:
ok 1 number(s): "314404834"
Test #26:
score: -100
Wrong Answer
time: 122ms
memory: 80216kb
input:
26 928302018 15796444138481 11937355225779 6149665857421 3432433989770 2307410764687 17243936548925 6178469381919 8828731666077 3415993426130 1036426554693 14386104368478 13448264214939 12599370135462 16273290761628 7852195291114 16757484794229 2980400729227 11047051074570 5685198104638 421391190008...
output:
11778 4302 19925 194470 68917 196684 47198 219331 21536 92354 205586 235047 20747 153939 7694 151885 38313 111272 34693 20117 47397 132912 2137 45428 144229 229307 988488604
result:
wrong answer 1st numbers differ - expected: '591376981', found: '11778'