QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#577280 | #9155. 集合 | thomaswmy# | 100 ✓ | 881ms | 100832kb | C++14 | 1.4kb | 2024-09-20 10:02:10 | 2024-09-20 10:02:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
const int M=1e6+10;
const int P=233;
typedef unsigned long long ull;
int n,m,q;
int A[N*3],B[N*3];
ull pp[N];
int RR[N];
int L,R;
ull hha[N*3],hhb[N*3];
unordered_map<ull,int> mpa,mpb;
int cnt;
void cng(ull *hh,int pos,unordered_map<ull,int> &mpa,unordered_map<ull,int> &mpb,ull val) {
ull now=hh[pos];
cnt-=mpa[now]==mpb[now];
mpa[now]--;
cnt+=mpa[now]==mpb[now];
hh[pos]=val;
now=hh[pos];
cnt-=mpa[now]==mpb[now];
mpa[now]++;
cnt+=mpa[now]==mpb[now];
}
void ins(int pos) {
for(int i=pos*3-2;i<=pos*3;i++) {
int vala=A[i];
cng(hha,vala,mpa,mpb,hha[vala]+pp[pos]);
int valb=B[i];
cng(hhb,valb,mpb,mpa,hhb[valb]+pp[pos]);
}
}
void del(int pos) {
for(int i=pos*3-2;i<=pos*3;i++) {
int vala=A[i];
cng(hha,vala,mpa,mpb,hha[vala]-pp[pos]);
int valb=B[i];
cng(hhb,valb,mpb,mpa,hhb[valb]-pp[pos]);
}
}
int main() {
scanf("%d%d%d",&n,&m,&q);
for(int i=1;i<=n*3;i++) scanf("%d",&A[i]);
for(int i=1;i<=n*3;i++) scanf("%d",&B[i]);
pp[0]=1;
for(int i=1;i<=n;i++) pp[i]=pp[i-1]*P;
L=1,R=0;
mpa[0]=mpb[0]=m;
for(int i=1;i<=n;i++) {
while(!cnt && R<n) ins(++R);
if(!cnt) RR[L]=R+1;
else RR[L]=R;
del(L++);
}
while(q--) {
int l,r;
scanf("%d%d",&l,&r);
if(RR[l]>r) printf("Yes\n");
else printf("No\n");
}
return 0;
}
Details
Pretests
Pretest #1:
score: 5
Accepted
time: 0ms
memory: 10132kb
Pretest #2:
score: 5
Accepted
time: 2ms
memory: 9944kb
Pretest #3:
score: 5
Accepted
time: 0ms
memory: 9956kb
Pretest #4:
score: 5
Accepted
time: 1ms
memory: 9968kb
Pretest #5:
score: 5
Accepted
time: 1ms
memory: 9940kb
Pretest #6:
score: 5
Accepted
time: 1ms
memory: 9972kb
Pretest #7:
score: 5
Accepted
time: 0ms
memory: 9940kb
Pretest #8:
score: 5
Accepted
time: 2ms
memory: 9960kb
Pretest #9:
score: 5
Accepted
time: 24ms
memory: 11936kb
Pretest #10:
score: 5
Accepted
time: 21ms
memory: 10196kb
Pretest #11:
score: 5
Accepted
time: 774ms
memory: 100832kb
Pretest #12:
score: 5
Accepted
time: 618ms
memory: 97324kb
Pretest #13:
score: 5
Accepted
time: 5ms
memory: 10588kb
Pretest #14:
score: 5
Accepted
time: 0ms
memory: 10632kb
Pretest #15:
score: 5
Accepted
time: 123ms
memory: 12732kb
Pretest #16:
score: 5
Accepted
time: 125ms
memory: 10636kb
Pretest #17:
score: 5
Accepted
time: 42ms
memory: 20872kb
Pretest #18:
score: 5
Accepted
time: 34ms
memory: 19104kb
Pretest #19:
score: 5
Accepted
time: 770ms
memory: 98120kb
Pretest #20:
score: 5
Accepted
time: 881ms
memory: 97364kb
Final Tests
Test #1:
score: 5
Accepted
time: 0ms
memory: 9964kb
Test #2:
score: 5
Accepted
time: 2ms
memory: 9972kb
Test #3:
score: 5
Accepted
time: 0ms
memory: 9880kb
Test #4:
score: 5
Accepted
time: 0ms
memory: 9840kb
Test #5:
score: 5
Accepted
time: 1ms
memory: 9964kb
Test #6:
score: 5
Accepted
time: 1ms
memory: 9960kb
Test #7:
score: 5
Accepted
time: 2ms
memory: 9968kb
Test #8:
score: 5
Accepted
time: 0ms
memory: 9928kb
Test #9:
score: 5
Accepted
time: 20ms
memory: 9940kb
Test #10:
score: 5
Accepted
time: 25ms
memory: 10008kb
Test #11:
score: 5
Accepted
time: 769ms
memory: 96944kb
Test #12:
score: 5
Accepted
time: 744ms
memory: 92848kb
Test #13:
score: 5
Accepted
time: 2ms
memory: 10940kb
Test #14:
score: 5
Accepted
time: 5ms
memory: 12780kb
Test #15:
score: 5
Accepted
time: 121ms
memory: 10752kb
Test #16:
score: 5
Accepted
time: 117ms
memory: 10932kb
Test #17:
score: 5
Accepted
time: 39ms
memory: 20884kb
Test #18:
score: 5
Accepted
time: 37ms
memory: 19056kb
Test #19:
score: 5
Accepted
time: 864ms
memory: 96588kb
Test #20:
score: 5
Accepted
time: 827ms
memory: 98160kb
Extra Test:
score: 0
Extra Test Passed