QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#502511#9155. 集合fryan100 ✓194ms34892kbC++141.8kb2024-08-03 08:13:572024-08-03 08:13:57

Judging History

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

  • [2024-08-03 08:13:57]
  • 评测
  • 测评结果:100
  • 用时:194ms
  • 内存:34892kb
  • [2024-08-03 08:13:57]
  • 提交

answer

//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define sz(x) (int) (x).size()
#define int int64_t
#define i128 __int128_t
#define all(x) (x).begin(), (x).end()
mt19937_64 rng(16582934);

const int mxn=2e5+5;
const int mxm=6e5+5;
int index_hash[mxn];

int n,m,q,a[mxn][3],b[mxn][3];
i128 ahash[mxm],bhash[mxm];
int right_point[mxn];

i128 chash_a = 0, chash_b = 0;

void add_a(int x, int ind) {
	chash_a -= ahash[x];
	ahash[x] ^= index_hash[ind];
	chash_a += ahash[x];
}
void add_b(int x, int ind) {
	chash_b -= bhash[x];
	bhash[x] ^= index_hash[ind];
	chash_b += bhash[x];
}

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	
	for (int i=0; i<mxn; i++) {
		index_hash[i] = rng();
	}
	
	cin>>n>>m>>q;
	for (int i=0; i<n; i++)
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	for (int i=0; i<n; i++)
		cin>>b[i][0]>>b[i][1]>>b[i][2];
	
	int rp=-1;
	for (int lp=0; lp<n; lp++) {
		while (chash_a == chash_b && rp < n) {
			rp++;
			for (int i=0; i<3; i++) {
				add_a(a[rp][i],rp);
				add_b(b[rp][i],rp);
			}
		}
		right_point[lp] = rp-1;
		for (int i=0; i<3; i++) {
			add_a(a[lp][i],lp);
			add_b(b[lp][i],lp);
		}
	}
	while (q--) {
		int l,r; cin>>l>>r; --l; --r;
		cout<<((r<=right_point[l])?"Yes":"No")<<"\n";
	}
    return 0;
}

Details


Pretests

Pretest #1:

score: 5
Accepted
time: 0ms
memory: 10608kb

Pretest #2:

score: 5
Accepted
time: 0ms
memory: 9228kb

Pretest #3:

score: 5
Accepted
time: 2ms
memory: 10856kb

Pretest #4:

score: 5
Accepted
time: 2ms
memory: 10656kb

Pretest #5:

score: 5
Accepted
time: 2ms
memory: 11216kb

Pretest #6:

score: 5
Accepted
time: 0ms
memory: 10600kb

Pretest #7:

score: 5
Accepted
time: 0ms
memory: 10412kb

Pretest #8:

score: 5
Accepted
time: 0ms
memory: 10216kb

Pretest #9:

score: 5
Accepted
time: 18ms
memory: 10620kb

Pretest #10:

score: 5
Accepted
time: 23ms
memory: 10968kb

Pretest #11:

score: 5
Accepted
time: 66ms
memory: 17152kb

Pretest #12:

score: 5
Accepted
time: 66ms
memory: 17636kb

Pretest #13:

score: 5
Accepted
time: 0ms
memory: 10128kb

Pretest #14:

score: 5
Accepted
time: 0ms
memory: 10336kb

Pretest #15:

score: 5
Accepted
time: 108ms
memory: 10372kb

Pretest #16:

score: 5
Accepted
time: 112ms
memory: 10548kb

Pretest #17:

score: 5
Accepted
time: 7ms
memory: 12560kb

Pretest #18:

score: 5
Accepted
time: 9ms
memory: 14388kb

Pretest #19:

score: 5
Accepted
time: 183ms
memory: 16596kb

Pretest #20:

score: 5
Accepted
time: 184ms
memory: 34808kb

Final Tests

Test #1:

score: 5
Accepted
time: 2ms
memory: 10688kb

Test #2:

score: 5
Accepted
time: 2ms
memory: 10956kb

Test #3:

score: 5
Accepted
time: 2ms
memory: 10452kb

Test #4:

score: 5
Accepted
time: 0ms
memory: 10404kb

Test #5:

score: 5
Accepted
time: 0ms
memory: 10500kb

Test #6:

score: 5
Accepted
time: 0ms
memory: 10264kb

Test #7:

score: 5
Accepted
time: 2ms
memory: 10780kb

Test #8:

score: 5
Accepted
time: 0ms
memory: 9224kb

Test #9:

score: 5
Accepted
time: 23ms
memory: 11252kb

Test #10:

score: 5
Accepted
time: 23ms
memory: 9916kb

Test #11:

score: 5
Accepted
time: 63ms
memory: 17476kb

Test #12:

score: 5
Accepted
time: 63ms
memory: 16732kb

Test #13:

score: 5
Accepted
time: 3ms
memory: 9244kb

Test #14:

score: 5
Accepted
time: 0ms
memory: 9440kb

Test #15:

score: 5
Accepted
time: 112ms
memory: 10872kb

Test #16:

score: 5
Accepted
time: 104ms
memory: 11176kb

Test #17:

score: 5
Accepted
time: 7ms
memory: 12384kb

Test #18:

score: 5
Accepted
time: 9ms
memory: 14072kb

Test #19:

score: 5
Accepted
time: 194ms
memory: 17276kb

Test #20:

score: 5
Accepted
time: 187ms
memory: 34892kb

Extra Test:

score: 0
Extra Test Passed