QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#277583 | #1780. Intact Intervals | wangqingxian | WA | 2ms | 11652kb | C++14 | 1.6kb | 2023-12-06 20:24:48 | 2023-12-06 20:24:48 |
Judging History
answer
#include<algorithm>
#include<vector>
#include<cstdio>
#include<map>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<iomanip>
#include<bitset>
#include<queue>
#include<cassert>
#include<stdlib.h>
#include<cmath>
#include<set>
#define ll long long
#define ld long double
#define For(i,l,r) for(int i=(l);i<=(r);++i)
#define rof(i,r,l) for(int i=(r);i>=(l);--i)
#define db double
#define mem0(a) memset(a,0,sizeof(a))
#define ull unsigned long long
#define lowbit(t) (t&-t)
#define uint unsigned int
//#define int long long
#define pii pair<int,int>
#define x1 dlskjfakljflkasd
#define y1 sldkfjalfjkalskl
#define x2 sdalkfjaklfjsdlk
#define y2 sfjaofoiwjfwfwof
using namespace std;
const int N=1e6+10,inf=2147483647,mod=998244353;
const ull base=1145141;
int n;
int a[N],b[N];
ull h1[N],h2[N];
ull fang[N];
int c[N],m;
int ans=0;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n;
For(i,1,n){cin>>a[i];c[++m]=a[i];}
For(i,1,n){cin>>b[i];c[++m]=b[i];}
sort(c+1,c+1+m);
m=unique(c+1,c+1+m)-c-1;
fang[0]=1;
For(i,1,n*2)fang[i]=fang[i-1]*base;
For(i,1,n){
h1[i]=h1[i-1]+fang[lower_bound(c+1,c+1+m,a[i])-c];
h2[i]=h1[i-1]+fang[lower_bound(c+1,c+1+m,b[i])-c];
h1[i]-=h2[i];
}
sort(h1+1,h1+1+n);
int j=0;
h1[0]=2098902489023840912;
For(i,1,n){
if(h1[i]!=h1[j]||i==n){
ans=(ans+(1<<(i-j))%mod-1)%mod;
j=i;
}
}
cout<<(ans-n+mod)%mod<<endl;
return 0;
}
/*
5
1 2 2 3 4
4 3 2 2 1
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 11652kb
input:
2 10 9 9 10
output:
0
result:
ok single line: '0'
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 11592kb
input:
5 3 6 9 10 6 3 10 6 9 6
output:
1
result:
wrong answer 1st lines differ - expected: '4', found: '1'