QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#101907 | #5827. 异或图 | Larunatrecy | Compile Error | / | / | C++14 | 2.9kb | 2023-05-01 21:04:45 | 2023-05-01 21:04:49 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-05-01 21:04:49]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-05-01 21:04:45]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 16;
const int mod = 998244353;
int f[2][2],g[2][2];
typedef long long LL;
LL solve(int n,LL *a,LL C)
{
if(!n) return C==0;
LL res=0;
for(int i=1;i<=n;i++)a[i]++;
for(int bit=60;bit>=0;bit--)
{
int c=0;
for(int i=1;i<=n;i++)
c+=((a[i]>>bit)&1ll);
if(c>0)
{
for(int u=0;u<=1;u++)
for(int v=0;v<=1;v++)
f[u][v]=g[u][v]=0;
f[0][0]=1;
for(int i=1;i<=n;i++)
{
int ka=(a[i]&((1ll<<bit)-1))%mod,bk=(1ll<<bit)%mod;
for(int u=0;u<=1;u++)
for(int v=0;v<=1;v++)
g[u][v]=0;
for(int u=0;u<=1;u++)
for(int v=0;v<=1;v++)
{
int up=((a[i]>>bit)&1ll);
for(int o=0;o<=up;o++)
{
int nu=0,nv=0,coef=1;
nv=(v^o);
if(u||o<up)nu=1;
if(u)
{
if(o<up)coef=bk;
else coef=ka;
}
else
{
if(o<up)coef=1;
else coef=ka;
}
g[nu][nv]=(g[nu][nv]+1ll*f[u][v]*coef%mod)%mod;
}
}
for(int u=0;u<=1;u++)
for(int v=0;v<=1;v++)
f[u][v]=g[u][v];
}
res=(res+f[1][(C>>bit)&1ll])%mod;
}
if((c&1)!=((C>>bit)&1ll))break;
}
for(int i=1;i<=n;i++)a[i]--;
return res;
}
int n,m;
LL C;
LL a[N],b[N];
int U[N*N],V[N*N];
int dp[14349907];
int Id[(1<<15)+7];
int pw[N];
int mn[(1<<N)],mx[(1<<N)],siz[(1<<N)],Q[(1<<N)],F[(1<<N)],E[(1<<N)];
int main()
{
freopen("graph.in","r",stdin);
freopen("graph.out","w",stdout);
cin>>n>>m>>C;
for(int i=1;i<=n;i++)scanf("%lld",&a[i]),b[i]=a[i];
for(int i=1;i<=m;i++)scanf("%d %d",&U[i],&V[i]);
if(m==0)
{
cout<<solve(n,a,C);
return 0;
}
for(int S=1;S<(1<<n);S++)
{
for(int i=1;i<=m;i++)
if((S>>(U[i]-1))%2==1&&(S>>(V[i]-1))%2==1)E[S]++;
}
F[0]=1;
for(int S=1;S<(1<<n);S++)
{
Q[S]=F[E[S]];
int x=0;
for(int i=1;i<=n;i++)
if((S>>(i-1))&1)x=i;
for(int T=(S-1)&S;T;T=(T-1)&S)
{
if((T>>(x-1))%2==0)continue;
Q[S]=(Q[S]-1ll*F[E[S^T]]*Q[T]%mod+mod)%mod;
}
}
for(int S=1;S<(1<<n);S++)
{
LL v=1e18;
for(int i=1;i<=n;i++)
{
if((S>>(i-1))%2==0)continue;
if(a[i]<v)v=a[i],mn[S]=i;
mx[S]=i;siz[S]++;
}
}
pw[0]=1;
for(int i=1;i<=n;i++)pw[i]=1ll*pw[i-1]*3;
for(int S=0;S<(1<<n);S++)
{
for(int i=1;i<=n;i++)
Id[S]+=((S>>(i-1))&1)*pw[i-1];
}
dp[Id[0]+Id[0]]=1;
for(int S=0;S<(1<<n);S++)
for(int T=S;;T=(T-1)&S)
{
if(dp[Id[S]+Id[T]])
{
int U=(1<<n)-1-S;
for(int A=U;A;A=(A-1)&U)
if(mx[A]>mx[S])
{
if(siz[A]%2==1)dp[Id[S|A]+Id[T|(1<<(mn[A]-1))]]=(dp[Id[S|A]+Id[T|(1<<(mn[A]-1))]]+1ll*dp[Id[S]+Id[T]]*Q[A]%mod)%mod;
else dp[Id[S|A]+Id[T]]=(dp[Id[S|A]+Id[T]]+1ll*dp[Id[S]+Id[T]]*Q[A]%mod*((a[mn[A]]+1)%mod)%mod)%mod;
}
}
if(!T)break;
}
int ans=0;
for(int S=1;S<(1<<n);S++)
{
int cnt=0;
for(int i=1;i<=n;i++)
if((S>>(i-1))&1)b[++cnt]=a[i];
ans=(ans+1ll*dp[Id[(1<<n)-1]+Id[S]]*solve(cnt,b,C)%mod)%mod;
}
cout<<ans;
return 0;
Details
answer.code: In function ‘int main()’: answer.code:142:18: error: expected ‘}’ at end of input 142 | return 0; | ^ answer.code:71:1: note: to match this ‘{’ 71 | { | ^ answer.code:72:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 72 | freopen("graph.in","r",stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ answer.code:73:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 73 | freopen("graph.out","w",stdout); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ answer.code:75:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 75 | for(int i=1;i<=n;i++)scanf("%lld",&a[i]),b[i]=a[i]; | ~~~~~^~~~~~~~~~~~~~ answer.code:76:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 76 | for(int i=1;i<=m;i++)scanf("%d %d",&U[i],&V[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~