# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
630374 |
2022-08-16T09:42:01 Z |
abeker |
Werewolf (IOI18_werewolf) |
C++17 |
|
3142 ms |
259304 KB |
#include <bits/stdc++.h>
#include "werewolf.h"
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
const int MAXN = 2e5 + 5;
struct dsu {
int dad[MAXN];
vector <int> comp[MAXN];
vector <pii> events[MAXN];
void init(int n, int t) {
for (int i = 1; i <= n; i++) {
events[i].push_back({t, i});
comp[i].push_back(i);
dad[i] = i;
}
}
void join(int x, int y) {
int timer = x;
x = dad[x];
y = dad[y];
if (x == y)
return;
if (comp[x].size() > comp[y].size())
swap(x, y);
for (auto it : comp[x]) {
events[it].push_back({timer, y});
comp[y].push_back(it);
dad[it] = y;
}
}
};
dsu up, down;
vector <int> adj[MAXN];
unordered_map <ll, int> mx, has;
vector <int> p[MAXN], f[MAXN];
vector <pli> q[MAXN];
pii where[MAXN];
void inc(vector <int> &v) {
for (auto &it : v)
it++;
}
inline ll hsh(pii p) {
return (ll)MAXN * p.first + p.second;
}
vector <int> check_validity(int N, vector <int> x, vector <int> y, vector <int> st, vector <int> en, vector <int> l, vector <int> r) {
int M = x.size();
int Q = st.size();
inc(x);
inc(y);
inc(st);
inc(en);
inc(l);
inc(r);
for (int i = 0; i < M; i++) {
adj[x[i]].push_back(y[i]);
adj[y[i]].push_back(x[i]);
}
for (int i = 0; i < Q; i++)
p[r[i]].push_back(i);
up.init(N, 0);
for (int i = 1; i <= N; i++) {
for (auto it : adj[i])
if (it <= i)
up.join(i, it);
for (auto it : p[i])
where[it].first = up.dad[en[it]];
}
for (int i = 1; i <= N; i++)
p[i].clear();
for (int i = 0; i < Q; i++)
p[l[i]].push_back(i);
down.init(N, N + 1);
for (int i = N; i; i--) {
for (auto it : adj[i])
if (it >= i)
down.join(i, it);
for (auto it : p[i])
where[it].second = down.dad[st[it]];
}
for (int i = 0; i < Q; i++)
has[hsh(where[i])] = 1;
for (int i = 1; i <= N; i++)
for (auto it1 : up.events[i])
for (auto it2 : down.events[i]) {
ll tmp = hsh({it1.second, it2.second});
if (has[tmp])
q[it1.first].push_back({tmp, it2.first});
}
for (int i = 0; i < Q; i++)
f[r[i]].push_back(i);
vector <int> ans(Q, 0);
for (int i = 0; i <= N; i++) {
for (auto it : q[i])
if (it.second > mx[it.first])
mx[it.first] = it.second;
for (auto it : f[i])
ans[it] = mx[hsh(where[it])] >= l[it];
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
37892 KB |
Output is correct |
2 |
Correct |
19 ms |
37844 KB |
Output is correct |
3 |
Correct |
19 ms |
37884 KB |
Output is correct |
4 |
Correct |
18 ms |
37800 KB |
Output is correct |
5 |
Correct |
19 ms |
37844 KB |
Output is correct |
6 |
Correct |
19 ms |
37884 KB |
Output is correct |
7 |
Correct |
18 ms |
37952 KB |
Output is correct |
8 |
Correct |
23 ms |
37844 KB |
Output is correct |
9 |
Correct |
22 ms |
37888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
37892 KB |
Output is correct |
2 |
Correct |
19 ms |
37844 KB |
Output is correct |
3 |
Correct |
19 ms |
37884 KB |
Output is correct |
4 |
Correct |
18 ms |
37800 KB |
Output is correct |
5 |
Correct |
19 ms |
37844 KB |
Output is correct |
6 |
Correct |
19 ms |
37884 KB |
Output is correct |
7 |
Correct |
18 ms |
37952 KB |
Output is correct |
8 |
Correct |
23 ms |
37844 KB |
Output is correct |
9 |
Correct |
22 ms |
37888 KB |
Output is correct |
10 |
Correct |
26 ms |
39700 KB |
Output is correct |
11 |
Correct |
26 ms |
39860 KB |
Output is correct |
12 |
Correct |
36 ms |
40732 KB |
Output is correct |
13 |
Correct |
25 ms |
39568 KB |
Output is correct |
14 |
Correct |
27 ms |
39952 KB |
Output is correct |
15 |
Correct |
28 ms |
39776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3142 ms |
259304 KB |
Output is correct |
2 |
Correct |
795 ms |
151524 KB |
Output is correct |
3 |
Correct |
963 ms |
171140 KB |
Output is correct |
4 |
Correct |
1760 ms |
222240 KB |
Output is correct |
5 |
Correct |
1860 ms |
229024 KB |
Output is correct |
6 |
Correct |
2349 ms |
245172 KB |
Output is correct |
7 |
Correct |
2970 ms |
251428 KB |
Output is correct |
8 |
Correct |
803 ms |
151460 KB |
Output is correct |
9 |
Correct |
1116 ms |
168920 KB |
Output is correct |
10 |
Correct |
1629 ms |
202948 KB |
Output is correct |
11 |
Correct |
1765 ms |
208360 KB |
Output is correct |
12 |
Correct |
2303 ms |
222020 KB |
Output is correct |
13 |
Correct |
851 ms |
150508 KB |
Output is correct |
14 |
Correct |
825 ms |
150372 KB |
Output is correct |
15 |
Correct |
835 ms |
150228 KB |
Output is correct |
16 |
Correct |
842 ms |
150428 KB |
Output is correct |
17 |
Correct |
2961 ms |
246824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
37892 KB |
Output is correct |
2 |
Correct |
19 ms |
37844 KB |
Output is correct |
3 |
Correct |
19 ms |
37884 KB |
Output is correct |
4 |
Correct |
18 ms |
37800 KB |
Output is correct |
5 |
Correct |
19 ms |
37844 KB |
Output is correct |
6 |
Correct |
19 ms |
37884 KB |
Output is correct |
7 |
Correct |
18 ms |
37952 KB |
Output is correct |
8 |
Correct |
23 ms |
37844 KB |
Output is correct |
9 |
Correct |
22 ms |
37888 KB |
Output is correct |
10 |
Correct |
26 ms |
39700 KB |
Output is correct |
11 |
Correct |
26 ms |
39860 KB |
Output is correct |
12 |
Correct |
36 ms |
40732 KB |
Output is correct |
13 |
Correct |
25 ms |
39568 KB |
Output is correct |
14 |
Correct |
27 ms |
39952 KB |
Output is correct |
15 |
Correct |
28 ms |
39776 KB |
Output is correct |
16 |
Correct |
3142 ms |
259304 KB |
Output is correct |
17 |
Correct |
795 ms |
151524 KB |
Output is correct |
18 |
Correct |
963 ms |
171140 KB |
Output is correct |
19 |
Correct |
1760 ms |
222240 KB |
Output is correct |
20 |
Correct |
1860 ms |
229024 KB |
Output is correct |
21 |
Correct |
2349 ms |
245172 KB |
Output is correct |
22 |
Correct |
2970 ms |
251428 KB |
Output is correct |
23 |
Correct |
803 ms |
151460 KB |
Output is correct |
24 |
Correct |
1116 ms |
168920 KB |
Output is correct |
25 |
Correct |
1629 ms |
202948 KB |
Output is correct |
26 |
Correct |
1765 ms |
208360 KB |
Output is correct |
27 |
Correct |
2303 ms |
222020 KB |
Output is correct |
28 |
Correct |
851 ms |
150508 KB |
Output is correct |
29 |
Correct |
825 ms |
150372 KB |
Output is correct |
30 |
Correct |
835 ms |
150228 KB |
Output is correct |
31 |
Correct |
842 ms |
150428 KB |
Output is correct |
32 |
Correct |
2961 ms |
246824 KB |
Output is correct |
33 |
Correct |
1866 ms |
206356 KB |
Output is correct |
34 |
Correct |
267 ms |
68452 KB |
Output is correct |
35 |
Correct |
1328 ms |
163180 KB |
Output is correct |
36 |
Correct |
2190 ms |
212632 KB |
Output is correct |
37 |
Correct |
1376 ms |
168028 KB |
Output is correct |
38 |
Correct |
2017 ms |
205468 KB |
Output is correct |
39 |
Correct |
1456 ms |
175192 KB |
Output is correct |
40 |
Correct |
1292 ms |
165264 KB |
Output is correct |
41 |
Correct |
1122 ms |
156760 KB |
Output is correct |
42 |
Correct |
1809 ms |
194076 KB |
Output is correct |
43 |
Correct |
1008 ms |
150812 KB |
Output is correct |
44 |
Correct |
1229 ms |
157540 KB |
Output is correct |
45 |
Correct |
992 ms |
152976 KB |
Output is correct |
46 |
Correct |
1214 ms |
162696 KB |
Output is correct |
47 |
Correct |
829 ms |
150640 KB |
Output is correct |
48 |
Correct |
832 ms |
150444 KB |
Output is correct |
49 |
Correct |
833 ms |
150716 KB |
Output is correct |
50 |
Correct |
821 ms |
150384 KB |
Output is correct |
51 |
Correct |
1241 ms |
158440 KB |
Output is correct |
52 |
Correct |
1198 ms |
159688 KB |
Output is correct |