QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#42316#1780. Intact IntervalsguapisoloWA 3ms7924kbC++141018b2022-08-01 22:02:092022-08-01 22:02:09

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-01 22:02:09]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:7924kb
  • [2022-08-01 22:02:09]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
using namespace std;
const int N1=1e6+5, p=1e9+7;


ll qpow(ll x,int y){
    ll ans=1;
    for(;y;x=x*x%p,y>>=1) if(y&1) ans=ans*x%p;
    return ans;
}
int n;
int a[N1],b[N1];
ull has[N1];
unordered_map<int,ull>rn;
unordered_map<ull,int>cnt;

int main()
{
    // freopen("1.in","r",stdin);
    scanf("%d",&n);
    mt19937_64 rnd(time(0));
    // for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    // for(int i=1;i<=n;i++) scanf("%d",&b[i]);
    for(int i=1;i<=n;i++) a[i]=rnd()%100000;
    for(int i=1;i<=n;i++) b[i]=rnd()%100000;
    for(int i=1;i<=n;i++){
        if(rn.find(a[i])==rn.end()){
            ll tmp=rnd();
            rn[a[i]]=tmp;
        }
    }
    for(int i=1;i<=n;i++){
        has[i]=has[i-1]+rn[a[i]]-rn[b[i]];
        cnt[has[i]]++;
    }
    ll ans=0;
    for(auto k:cnt){
        ans=((ans+qpow(2,k.second)-k.second-1)%p+p)%p;
    }
    printf("%lld\n",ans);
    return 0; 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 7836kb

input:

2
10 9
9 10

output:

0

result:

ok single line: '0'

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 7924kb

input:

5
3 6 9 10 6
3 10 6 9 6

output:

0

result:

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