QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#533201 | #9155. 集合 | chenshi | 100 ✓ | 728ms | 91480kb | C++17 | 1.0kb | 2024-08-25 18:28:13 | 2024-08-25 18:28:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 6e5 + 10;
int n, m, q, ans[N], bad;
unsigned long long w[N];
mt19937 rnd(time(0));
map<unsigned long long, int> mp;
struct s{
int v[N][3], coef;
unsigned long long t[N];
void init(int c) {
for(int i = 1; i <= n; i++)
for(int j = 0; j < 3; j++)
cin >> v[i][j];
coef = c;
}
void upd(int p, int c) {
for(int i = 0; i < 3; i++) {
auto u1 = &mp[t[v[p][i]]];
bad -= !!*u1, *u1 -= coef, bad += !!*u1;
t[v[p][i]] += c * w[p];
auto u2 = &mp[t[v[p][i]]];
bad -= !!*u2, *u2 += coef, bad += !!*u2;
}
}
}a, b;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cin >> n >> m >> q;
for(int i = 1; i <= n; i++) w[i] = rnd();
a.init(1), b.init(-1);
for(int l = 1, r = 1; r <= n; r++) {
a.upd(r, 1), b.upd(r, 1);
while(bad) a.upd(l, -1), b.upd(l, -1), l++;
ans[r] = l;
}
while(q--) {
int l, r;
cin >> l >> r;
cout << ((l >= ans[r]) ? "Yes\n" : "No\n");
}
return 0;
}
Details
Pretests
Pretest #1:
score: 5
Accepted
time: 0ms
memory: 11900kb
Pretest #2:
score: 5
Accepted
time: 2ms
memory: 11980kb
Pretest #3:
score: 5
Accepted
time: 0ms
memory: 11980kb
Pretest #4:
score: 5
Accepted
time: 0ms
memory: 11980kb
Pretest #5:
score: 5
Accepted
time: 2ms
memory: 11848kb
Pretest #6:
score: 5
Accepted
time: 0ms
memory: 11896kb
Pretest #7:
score: 5
Accepted
time: 0ms
memory: 12016kb
Pretest #8:
score: 5
Accepted
time: 2ms
memory: 11944kb
Pretest #9:
score: 5
Accepted
time: 16ms
memory: 11940kb
Pretest #10:
score: 5
Accepted
time: 21ms
memory: 11976kb
Pretest #11:
score: 5
Accepted
time: 588ms
memory: 91480kb
Pretest #12:
score: 5
Accepted
time: 607ms
memory: 80392kb
Pretest #13:
score: 5
Accepted
time: 3ms
memory: 14668kb
Pretest #14:
score: 5
Accepted
time: 2ms
memory: 12380kb
Pretest #15:
score: 5
Accepted
time: 90ms
memory: 12720kb
Pretest #16:
score: 5
Accepted
time: 109ms
memory: 12440kb
Pretest #17:
score: 5
Accepted
time: 41ms
memory: 18928kb
Pretest #18:
score: 5
Accepted
time: 36ms
memory: 17776kb
Pretest #19:
score: 5
Accepted
time: 722ms
memory: 85492kb
Pretest #20:
score: 5
Accepted
time: 665ms
memory: 78768kb
Final Tests
Test #1:
score: 5
Accepted
time: 0ms
memory: 11968kb
Test #2:
score: 5
Accepted
time: 2ms
memory: 11964kb
Test #3:
score: 5
Accepted
time: 1ms
memory: 11884kb
Test #4:
score: 5
Accepted
time: 2ms
memory: 11920kb
Test #5:
score: 5
Accepted
time: 0ms
memory: 11976kb
Test #6:
score: 5
Accepted
time: 2ms
memory: 11888kb
Test #7:
score: 5
Accepted
time: 0ms
memory: 11896kb
Test #8:
score: 5
Accepted
time: 2ms
memory: 11960kb
Test #9:
score: 5
Accepted
time: 20ms
memory: 12032kb
Test #10:
score: 5
Accepted
time: 20ms
memory: 12040kb
Test #11:
score: 5
Accepted
time: 623ms
memory: 82664kb
Test #12:
score: 5
Accepted
time: 594ms
memory: 80284kb
Test #13:
score: 5
Accepted
time: 6ms
memory: 12496kb
Test #14:
score: 5
Accepted
time: 0ms
memory: 12388kb
Test #15:
score: 5
Accepted
time: 96ms
memory: 12680kb
Test #16:
score: 5
Accepted
time: 102ms
memory: 12428kb
Test #17:
score: 5
Accepted
time: 47ms
memory: 21052kb
Test #18:
score: 5
Accepted
time: 43ms
memory: 20156kb
Test #19:
score: 5
Accepted
time: 728ms
memory: 82308kb
Test #20:
score: 5
Accepted
time: 665ms
memory: 82524kb
Extra Test:
score: 0
Extra Test Passed