QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#657823#9482. Count Pseudo-Palindromesucup-team3161#WA 2105ms133864kbC++201.1kb2024-10-19 15:32:112024-10-19 15:32:12

Judging History

This is the latest submission verdict.

  • [2024-10-19 15:32:12]
  • Judged
  • Verdict: WA
  • Time: 2105ms
  • Memory: 133864kb
  • [2024-10-19 15:32:11]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define eb emplace_back
const int N=1e6+5;
mt19937 rand1(0);
int n,a[N],b[N],nw[N];ll ans[N];ull s[N],w[N];
set<int> z;map<ull,int> mp;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i) w[i]=1<<i;//rand1();
    for(int i=1;i<=n*2;++i) scanf("%d",&a[i]);
    for(int i=1;i<=n*2;++i)
    {int &t=nw[a[i]];if(t) b[i]=t,b[t]=i;t=i;}
    for(int i=1;i<=n*2;++i) s[i]=s[i-1]^w[a[i]];
    for(int i=1,t;i<=n*2;++i)
    {
        ++mp[s[i-1]];
        if(i<b[i]) z.insert(i);else z.erase(b[i]);
        if(!z.empty())
        {
            t=*prev(z.end());
            ans[t]+=mp[s[i]^w[a[t]]];
        }
    }
    z.clear();mp.clear();
    for(int i=n*2,t;i;--i)
    {
        ++mp[s[i]];
        if(i>b[i]) z.insert(i);else z.erase(b[i]);
        if(!z.empty())
        {            
            t=*z.begin();
            ans[t]+=mp[s[i-1]^w[a[t]]];
        }
    }
    for(int i=1;i<=n*2;++i) printf("%lld ",ans[i]);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
1 1 2 2

output:

1 2 2 1 

result:

ok 4 tokens

Test #2:

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

input:

3
2 1 2 3 1 3

output:

1 2 2 2 2 1 

result:

ok 6 tokens

Test #3:

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

input:

4
1 2 4 3 4 1 3 2

output:

1 2 1 2 1 3 1 1 

result:

ok 8 tokens

Test #4:

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

input:

1
1 1

output:

1 1 

result:

ok 2 tokens

Test #5:

score: -100
Wrong Answer
time: 2105ms
memory: 133864kb

input:

500000
233733 151347 468353 495903 234861 297169 312993 2734 287872 359375 79017 285205 219439 37290 409190 194953 306816 472906 123794 121028 66509 62235 385879 300188 485875 72413 167304 333428 33910 220100 151575 22575 206653 82054 111518 34032 48702 198940 6262 222529 170641 1735 38943 235003 11...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 ...

result:

wrong answer 104th words differ - expected: '1', found: '2'