QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#88462 | #5827. 异或图 | ooooxxxx | 10 | 3ms | 4396kb | C++14 | 1.9kb | 2023-03-16 11:39:13 | 2023-03-16 11:39:15 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int mod=998244353;
#define int long long
const int N=15;
int n,m,c;
int a[N],A[N];
vector<int>dp[(1<<15)+10];
int ban[(1<<15)+10];
#define rep(i,l,r) for(int i=l;i<=r;i++)
inline int solve(int s){
vector<int>b;
int ans=0;
for(int i=0;i<n;i++)
if((s>>i)&1) b.push_back(a[i]);
for(int i=60;i>=0;i--){
int sum=0;
for(int x:b)sum^=((x>>(i+1)));
if(sum==(c>>(i+1))){
static int f[2][2],g[2][2];
memset(f,0,sizeof(f));
f[0][0]=1;
for(int x:b){
if((x>>i)&1){
int s0=(1ll<<i)%mod;
int s1=(x&((1ll<<i)-1))+1;s1%=mod;
g[0][0]=f[0][1]*s1;
g[0][1]=f[0][0]*s1;
g[1][0]=f[1][0]*s0+f[1][1]*s1+f[0][0];
g[1][1]=f[1][1]*s0+f[1][0]*s1+f[0][1];
rep(u,0,1)rep(v,0,1) f[u][v]=g[u][v]%mod;
}else{
int cur=(x&((1ll<<i)-1))+1;cur%=mod;
rep(u,0,1)rep(v,0,1) f[u][v]=f[u][v]*cur%mod;
}
}
ans+=f[1][(c>>i)&1];
ans%=mod;
}
}return ans;
}
int32_t main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n>>m>>c;
for(int i=0;i<n;i++) cin>>a[i];
static int p[N],q[N];
for(int i=0;i<n;i++) p[i]=i;
sort(p,p+n,[&](int u,int v){
return a[u]<a[v];
});
for(int i=0;i<n;i++) q[p[i]]=i;
sort(a,a+n);
for(int i=1;i<=m;i++){
int x,y;cin>>x>>y;x--,y--;
ban[(1<<q[x])+(1<<q[y])]=1;
}
for(int mid=1;mid<(1<<n);mid<<=1){
for(int j=0;j<(1<<n);j+=(mid<<1))
for(int k=0;k<mid;k++)ban[j+k+mid]|=ban[j+k];
}
cout<<solve((1<<n)-1);
// for(int b=60;b>=0;b--){
// }
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 4116kb
input:
4 6 2 7 11 14 0 1 2 1 3 2 3 2 4 4 1 4 3
output:
91
result:
wrong answer 1st numbers differ - expected: '44', found: '91'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 10
Accepted
Test #47:
score: 10
Accepted
time: 2ms
memory: 4396kb
input:
14 0 731833687287532167 157552918690640051 900457311668526045 111217720157614956 84140984111060473 814012186135880499 784848789620248379 958953377683017264 105083874298571687 104921429970878846 44983041675142735 871013110538758030 686733907990421995 98063590462078176 495161493555059993
output:
231790380
result:
ok 1 number(s): "231790380"
Test #48:
score: 0
Accepted
time: 1ms
memory: 4268kb
input:
11 0 101435837408688522 638776638580507479 933944392115323974 19098604312360490 142362319980029593 419910251764515410 275591812677260089 770239593400917018 928344484461634421 67340905784404712 378109786925249078 110881245457449811
output:
242383534
result:
ok 1 number(s): "242383534"
Test #49:
score: 0
Accepted
time: 3ms
memory: 4104kb
input:
9 0 100988561775675251 622570387572403506 684352103903274038 784649864569409753 270298495621205212 56183537059869110 346856482529145989 86639702870530669 607198038565138736 14747634008501988
output:
20893166
result:
ok 1 number(s): "20893166"
Test #50:
score: 0
Accepted
time: 3ms
memory: 4116kb
input:
10 0 839910859917247463 611237879350518457 292219463776059962 548211857317940894 822255554598388425 335628456629874391 774414280870858683 882480367082748768 654587410087321403 74330774886125511 22894883233341926
output:
61697734
result:
ok 1 number(s): "61697734"
Subtask #4:
score: 0
Skipped
Dependency #1:
0%