QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#493229 | #9155. 集合 | hhiron | 100 ✓ | 683ms | 118624kb | C++14 | 1.9kb | 2024-07-26 22:13:23 | 2024-07-26 22:13:23 |
Judging History
answer
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define int long long
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int N=5e6+5;
const ll MOD=100000000000000003;
mt19937_64 rnd(time(0));
int n,m,q,a[N][3],b[N][3],maxr[N];
ull id[N],sita[N],sitb[N];
unordered_map<ull,int> cnta,cntb;
bool check(int x){
for(int i=0;i<3;i++){
ull aa=sita[a[x][i]],bb=sitb[b[x][i]];
cnta[aa%MOD]--,cntb[bb%MOD]--;
cnta[(aa+id[x])%MOD]++,cntb[(bb+id[x])%MOD]++;
}bool lrc=1;
for(int i=0;i<3;i++){
ull aa=sita[a[x][i]],bb=sitb[b[x][i]];
if(cnta[aa%MOD]!=cntb[aa%MOD]) lrc=0;
if(cnta[bb%MOD]!=cntb[bb%MOD]) lrc=0;
if(cnta[(aa+id[x])%MOD]!=cntb[(aa+id[x])%MOD]) lrc=0;
if(cnta[(bb+id[x])%MOD]!=cntb[(bb+id[x])%MOD]) lrc=0;
}if(lrc){
for(int i=0;i<3;i++){
sita[a[x][i]]=(sita[a[x][i]]+id[x]);
sitb[b[x][i]]=(sitb[b[x][i]]+id[x]);
}return 1;
}else{
for(int i=0;i<3;i++){
ull aa=sita[a[x][i]],bb=sitb[b[x][i]];
cnta[aa%MOD]++,cntb[bb%MOD]++;
cnta[(aa+id[x])%MOD]--,cntb[(bb+id[x])%MOD]--;
}return 0;
}
}
signed main(){
//freopen("ex_4.in","r",stdin);
//freopen("task.out","w",stdout);
scanf("%lld%lld%lld",&n,&m,&q);
for(int i=1;i<=n;i++) scanf("%lld%lld%lld",&a[i][0],&a[i][1],&a[i][2]);
for(int i=1;i<=n;i++) scanf("%lld%lld%lld",&b[i][0],&b[i][1],&b[i][2]);
int r=0;
for(int i=1;i<=n;i++) id[i]=rnd();
for(int l=1;l<=n;l++){
while(r<=n){
if(check(r+1)) r++;
else break;
}maxr[l]=r;
// cout<<l<<" "<<maxr[l]<<endl;
for(int j=0;j<3;j++){
ull aa=sita[a[l][j]],bb=sitb[b[l][j]];
// cout<<a[l][j]<<"!"<<b[l][j]<<endl;
cnta[aa%MOD]--,cntb[bb%MOD]--;
sita[a[l][j]]=aa-id[l];
sitb[b[l][j]]=bb-id[l];
cnta[sita[a[l][j]]%MOD]++;
cntb[sitb[b[l][j]]%MOD]++;
}
}for(int i=1,a,b;i<=q;i++){
scanf("%lld%lld",&a,&b);
//cout<<a<<"!"<<maxr[a]<<" "<<b<<endl;
if(b>maxr[a]) printf("No\n");
else printf("Yes\n");
}
return 0;
}
詳細信息
Pretests
Pretest #1:
score: 5
Accepted
time: 2ms
memory: 12096kb
Pretest #2:
score: 5
Accepted
time: 0ms
memory: 12336kb
Pretest #3:
score: 5
Accepted
time: 1ms
memory: 12000kb
Pretest #4:
score: 5
Accepted
time: 0ms
memory: 12280kb
Pretest #5:
score: 5
Accepted
time: 1ms
memory: 11996kb
Pretest #6:
score: 5
Accepted
time: 1ms
memory: 12092kb
Pretest #7:
score: 5
Accepted
time: 1ms
memory: 12352kb
Pretest #8:
score: 5
Accepted
time: 1ms
memory: 12076kb
Pretest #9:
score: 5
Accepted
time: 22ms
memory: 12060kb
Pretest #10:
score: 5
Accepted
time: 15ms
memory: 11996kb
Pretest #11:
score: 5
Accepted
time: 630ms
memory: 118624kb
Pretest #12:
score: 5
Accepted
time: 554ms
memory: 113272kb
Pretest #13:
score: 5
Accepted
time: 2ms
memory: 13060kb
Pretest #14:
score: 5
Accepted
time: 4ms
memory: 12840kb
Pretest #15:
score: 5
Accepted
time: 119ms
memory: 13092kb
Pretest #16:
score: 5
Accepted
time: 114ms
memory: 12928kb
Pretest #17:
score: 5
Accepted
time: 38ms
memory: 21216kb
Pretest #18:
score: 5
Accepted
time: 27ms
memory: 23216kb
Pretest #19:
score: 5
Accepted
time: 679ms
memory: 116288kb
Pretest #20:
score: 5
Accepted
time: 656ms
memory: 114060kb
Final Tests
Test #1:
score: 5
Accepted
time: 2ms
memory: 12068kb
Test #2:
score: 5
Accepted
time: 0ms
memory: 11984kb
Test #3:
score: 5
Accepted
time: 1ms
memory: 12008kb
Test #4:
score: 5
Accepted
time: 1ms
memory: 11996kb
Test #5:
score: 5
Accepted
time: 0ms
memory: 11984kb
Test #6:
score: 5
Accepted
time: 0ms
memory: 12000kb
Test #7:
score: 5
Accepted
time: 1ms
memory: 12056kb
Test #8:
score: 5
Accepted
time: 1ms
memory: 12116kb
Test #9:
score: 5
Accepted
time: 22ms
memory: 12048kb
Test #10:
score: 5
Accepted
time: 19ms
memory: 12056kb
Test #11:
score: 5
Accepted
time: 593ms
memory: 113220kb
Test #12:
score: 5
Accepted
time: 539ms
memory: 112812kb
Test #13:
score: 5
Accepted
time: 5ms
memory: 12780kb
Test #14:
score: 5
Accepted
time: 0ms
memory: 12792kb
Test #15:
score: 5
Accepted
time: 109ms
memory: 12864kb
Test #16:
score: 5
Accepted
time: 110ms
memory: 13148kb
Test #17:
score: 5
Accepted
time: 42ms
memory: 21396kb
Test #18:
score: 5
Accepted
time: 41ms
memory: 25268kb
Test #19:
score: 5
Accepted
time: 676ms
memory: 113968kb
Test #20:
score: 5
Accepted
time: 683ms
memory: 115136kb
Extra Test:
score: 0
Extra Test Passed