QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#572706#9305. Steins;Gamerotcar07WA 1ms5644kbC++201.7kb2024-09-18 16:02:062024-09-18 16:02:06

Judging History

This is the latest submission verdict.

  • [2024-09-18 16:02:06]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5644kb
  • [2024-09-18 16:02:06]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll mod=1e9+7;
constexpr int maxn=1e5+5;
ll pw[maxn];
ll a[maxn];int n;
ll B[60];int cnt=0;
template<typename T,typename TT>inline T qpow(T a,TT b){T ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod;b>>=1;}return ans;}template<typename T>inline T qpow(T a){return qpow(a*1ll,mod-2);}
ll fac[maxn],inv[maxn];
inline void initfac(int n){
    fac[0]=1;for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mod;
    inv[n]=qpow(fac[n]);for(int i=n-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
inline ll C(int n,int m){if(n<0||m<0||n<m)return 0;else return fac[n]*inv[n-m]%mod*inv[m]%mod;}
int lst[maxn];
int main(){
    cin>>n;for(int i=pw[0]=1;i<=n;i++) cin>>a[i],pw[i]=pw[i-1]*2%mod;
    initfac(n);
    sort(a+1,a+n+1);
    int w=0;ll chk=0,ful,ans=0,res=0;
    for(int i=1;i<=n;i++) chk^=a[i];ful=chk;
    for(int i=1;i<=n;i++) cout<<a[i]<<' ';cout<<'\n';
    if(!ful) ans=1;
    for(int i=1;i<=n;i++) lst[i]=(a[i]==a[i-1]?lst[i-1]:i);
    for(int i=n;i>=1;i--){
        w++;chk^=a[i];
        {
            res=0;
            ll x=(chk^(a[i]-w%2));
            if(!(ful^(w%2?a[i]:0)^(a[i]-(w+1)%2))) res++; 
            if(!(ful^(w%2?a[i]:0)^(a[i]-w%2))) res--;
            for(int i=59;i>=0;i--) if(x>>i&1) x^=B[i];
            if(!x) res+=pw[cnt];
            ans+=res%mod*C(w+i-lst[i],w)%mod;
        }
        if(a[i]!=a[i-1]){
            ll x=a[i];
            for(int i=59;i>=0;i--)if(x>>i&1){
                if(!B[i]){B[i]=x;break;}
                x^=B[i];
            }
            cnt+=w-1;
            if(!x) cnt++;w=0;
        }
        // cout<<i<<' '<<cnt<<' '<<ans<<' '<<w<<'\n';
    }
    // cout<<cnt<<'\n';
    cout<<ans%mod<<'\n';
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5644kb

input:

2
1 1

output:

1 1 
4

result:

wrong answer 1st numbers differ - expected: '4', found: '1'