QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499344#8520. Xor PartitionsDecade#WA 1ms5740kbC++172.0kb2024-07-31 13:00:472024-07-31 13:00:48

Judging History

你现在查看的是最新测评结果

  • [2024-07-31 13:00:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5740kb
  • [2024-07-31 13:00:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int, int> PII;
mt19937 rng;
uniform_int_distribution <ull> dist(0,1ull<<63);
//#define mp make_pair
inline void print(__int128 x){//输出模板 
    if(x<0){
        putchar('-');
        x=-x;
    }
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
inline int read()
{
    int X = 0;
    bool flag = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            flag = 0;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        X = (X << 1) + (X << 3) + ch - '0';
        ch = getchar();
    }
    if (flag)
        return X;
    return ~(X - 1);
}
const LL mod = 1e9 + 7,INF = 0x3f3f3f3f;
LL qpow(LL a, LL b)
{
    LL res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }
const int N = 300010,M = 1000010;

int f[N],a[N],val[70][2],tmp[70];

void solve()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    
    f[0] = 1;
    for(int i=1;i<=n;i++)
    {
        int t = a[i],idx = 0;
        for(int j=0;j<=60;j++) tmp[j] = 0;
        while(t)
        {
            tmp[idx++] = t%2;
            t >>= 1;
        }
        for(int j=0;j<=60;j++)
        {
            if(tmp[j])
            {
                swap(val[j][0],val[j][1]);
            }
        }
        for(int j=0;j<=60;j++) (val[j][tmp[j]] += f[i-1]) %= mod;
        for(int j=0;j<=60;j++) f[i] += (1<<j)*val[j][1]%mod,f[i] %= mod;
    }
    cout<<f[n]<<'\n';
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5648kb

input:

4
7 3 1 2

output:

170

result:

ok 1 number(s): "170"

Test #2:

score: 0
Accepted
time: 1ms
memory: 5648kb

input:

1
0

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 1ms
memory: 5636kb

input:

1
1

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 1ms
memory: 5648kb

input:

3
1 2 3

output:

16

result:

ok 1 number(s): "16"

Test #5:

score: 0
Accepted
time: 0ms
memory: 5704kb

input:

4
0 1 0 1

output:

2

result:

ok 1 number(s): "2"

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 5740kb

input:

562
918479109239293921 960173570446350728 374394588863436385 418106819278123099 473761712658352147 662782574081105364 824954323015093862 827581845536521847 184394794881199801 820907621998888642 606529830885621237 961790689782125501 582742201855597942 337901250755571075 287706594894797714 18578215893...

output:

910272497

result:

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