QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#42316 | #1780. Intact Intervals | guapisolo | WA | 3ms | 7924kb | C++14 | 1018b | 2022-08-01 22:02:09 | 2022-08-01 22:02:09 |
Judging History
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'