QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#489677 | #9155. 集合 | yemuzhe | 100 ✓ | 220ms | 46600kb | C++14 | 1.3kb | 2024-07-24 22:42:29 | 2024-07-24 22:42:29 |
Judging History
answer
#include <cstdio>
#include <random>
#include <ctime>
#define N 600005
#define uid() uniform_int_distribution<unsigned long long>()(rnd)
using namespace std;
const int k = 3;
int n, m, q, a[N], b[N], r[N];
unsigned long long mp[k][N], vala[k][N], valb[k][N], nowa[k], nowb[k];
mt19937 rnd (time (0));
bool eq (unsigned long long *a, unsigned long long *b)
{
for (int i = 0; i < k; i ++)
{
if (a[i] != b[i]) return 0;
}
return 1;
}
void insert (int i)
{
for (int j = (i - 1) * 3 + 1; j <= i * 3; j ++)
{
for (int u = 0; u < k; u ++)
{
nowa[u] -= vala[u][a[j]];
vala[u][a[j]] ^= mp[u][i];
nowa[u] += vala[u][a[j]];
nowb[u] -= valb[u][b[j]];
valb[u][b[j]] ^= mp[u][i];
nowb[u] += valb[u][b[j]];
}
}
return ;
}
int main ()
{
scanf ("%d%d%d", &n, &m, &q);
for (int i = 1; i <= n; i ++)
{
for (int j = 0; j < k; j ++)
{
mp[j][i] = uid ();
}
}
for (int i = 1; i <= n * 3; i ++)
{
scanf ("%d", &a[i]);
}
for (int i = 1; i <= n * 3; i ++)
{
scanf ("%d", &b[i]);
}
for (int i = 1, j = 0; i <= n; i ++)
{
while (j < n)
{
insert (j + 1);
if (eq (nowa, nowb)) j ++;
else {insert (j + 1); break;}
}
r[i] = j, insert (i);
}
for (int i = 1, x, y; i <= q; i ++)
{
scanf ("%d%d", &x, &y);
puts (y <= r[x] ? "Yes" : "No");
}
return 0;
}
Details
Pretests
Pretest #1:
score: 5
Accepted
time: 0ms
memory: 13776kb
Pretest #2:
score: 5
Accepted
time: 2ms
memory: 13736kb
Pretest #3:
score: 5
Accepted
time: 0ms
memory: 13772kb
Pretest #4:
score: 5
Accepted
time: 0ms
memory: 13788kb
Pretest #5:
score: 5
Accepted
time: 0ms
memory: 13732kb
Pretest #6:
score: 5
Accepted
time: 2ms
memory: 13940kb
Pretest #7:
score: 5
Accepted
time: 0ms
memory: 13772kb
Pretest #8:
score: 5
Accepted
time: 0ms
memory: 13864kb
Pretest #9:
score: 5
Accepted
time: 21ms
memory: 13824kb
Pretest #10:
score: 5
Accepted
time: 17ms
memory: 13780kb
Pretest #11:
score: 5
Accepted
time: 85ms
memory: 19072kb
Pretest #12:
score: 5
Accepted
time: 85ms
memory: 19776kb
Pretest #13:
score: 5
Accepted
time: 3ms
memory: 13904kb
Pretest #14:
score: 5
Accepted
time: 0ms
memory: 14056kb
Pretest #15:
score: 5
Accepted
time: 104ms
memory: 13792kb
Pretest #16:
score: 5
Accepted
time: 99ms
memory: 14052kb
Pretest #17:
score: 5
Accepted
time: 10ms
memory: 15960kb
Pretest #18:
score: 5
Accepted
time: 4ms
memory: 18692kb
Pretest #19:
score: 5
Accepted
time: 189ms
memory: 19748kb
Pretest #20:
score: 5
Accepted
time: 215ms
memory: 46600kb
Final Tests
Test #1:
score: 5
Accepted
time: 2ms
memory: 13804kb
Test #2:
score: 5
Accepted
time: 0ms
memory: 13888kb
Test #3:
score: 5
Accepted
time: 0ms
memory: 13792kb
Test #4:
score: 5
Accepted
time: 2ms
memory: 13856kb
Test #5:
score: 5
Accepted
time: 0ms
memory: 13788kb
Test #6:
score: 5
Accepted
time: 0ms
memory: 13896kb
Test #7:
score: 5
Accepted
time: 2ms
memory: 13792kb
Test #8:
score: 5
Accepted
time: 0ms
memory: 13856kb
Test #9:
score: 5
Accepted
time: 21ms
memory: 13832kb
Test #10:
score: 5
Accepted
time: 17ms
memory: 13732kb
Test #11:
score: 5
Accepted
time: 88ms
memory: 20164kb
Test #12:
score: 5
Accepted
time: 82ms
memory: 19644kb
Test #13:
score: 5
Accepted
time: 3ms
memory: 13824kb
Test #14:
score: 5
Accepted
time: 0ms
memory: 14068kb
Test #15:
score: 5
Accepted
time: 92ms
memory: 13924kb
Test #16:
score: 5
Accepted
time: 94ms
memory: 14052kb
Test #17:
score: 5
Accepted
time: 9ms
memory: 13796kb
Test #18:
score: 5
Accepted
time: 13ms
memory: 18592kb
Test #19:
score: 5
Accepted
time: 195ms
memory: 22664kb
Test #20:
score: 5
Accepted
time: 220ms
memory: 46588kb
Extra Test:
score: 0
Extra Test Passed