# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
243956 | 2020-07-02T11:36:20 Z | crossing0ver | Werewolf (IOI18_werewolf) | C++17 | 836 ms | 125848 KB |
#include "werewolf.h" #include<bits/stdc++.h> #define x first #define y second #define pb push_back #define eb emplace_back #define all(a) (a).begin(),(a).end() #define SZ(a) (int)(a).size() using namespace std; typedef long long LL; typedef pair<LL,LL> PLL; typedef pair<int,int> PII; typedef double D; typedef long double LD; typedef vector<int> VI; const int N = 200005, Q = 400005; int n, q, m; struct A{ int q, u, t; bool operator <(const A& o) const{ return t<o.t; } }; vector<int> g[N], G[N], ans; vector<A> H, WW; int P[Q], sz[Q], ll[Q], rr[Q], p[N], dp[N], T; int st[N], en[N]; set<int> node[N]; set<int>::iterator IT; int fin(int i){ if(p[i]==i) return i; return fin(p[i]); } void merg(int a, int b, bool ww){ a = fin(a); b = fin(b); if(a == b) return ; if(dp[a]<dp[b]) swap(a,b); if(!ww) G[a].pb(b); else{ for(int it : node[b]) node[a].insert(it); } p[b] = a; dp[a] += dp[b]; } void dfs(int u){ st[u] = ++T; for(int e : G[u]) dfs(e); en[u] = T; } VI check_validity(int nn, VI X, VI Y, VI S, VI E, VI L, VI R) { q = SZ(S); n = nn; m = SZ(X); ans.resize(q); int i,j,k,l,a,b,c,d; for(i=0;i<m;i++){ g[X[i]].pb(Y[i]); g[Y[i]].pb(X[i]); } for(i=0;i<q;i++){ H.pb({i, S[i], L[i]}); WW.pb({i, E[i], R[i]}); } sort(all(H)); sort(all(WW)); // human preparation int nw; nw = q-1; for(i=0;i<n;i++) p[i]=i, dp[i]=1; for(i=n-1;i>=0;i--){ for(int e : g[i]){ if(e > i) merg(i,e,false); } while(nw>=0 && H[nw].t == i){ a = fin(H[nw].u); b = H[nw].q; P[b] = a; sz[b] = dp[a]; nw--; } } for(i=0;i<n;i++){ if(p[i]==i) { dfs(i);break;} } for(i=0;i<q;i++){ ll[i] = st[P[i]]; rr[i] = st[P[i]]+sz[i]-1; } // werewolf prepareation nw=0; for(i=0;i<n;i++){ p[i] = i; dp[i] = 1; node[i].insert(st[i]); } for(i=0;i<n;i++){ for(int e : g[i]){ if(e < i) merg(i, e, true); } while(nw<q && WW[nw].t == i){ a = fin(WW[nw].u); b = WW[nw].q; IT = node[a].lower_bound(ll[b]); if(IT != node[a].end() && *IT <= rr[b]) ans[b] = 1; nw++; } } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 19200 KB | Output is correct |
2 | Correct | 17 ms | 19200 KB | Output is correct |
3 | Correct | 15 ms | 19200 KB | Output is correct |
4 | Correct | 15 ms | 19200 KB | Output is correct |
5 | Correct | 17 ms | 19200 KB | Output is correct |
6 | Correct | 15 ms | 19200 KB | Output is correct |
7 | Correct | 15 ms | 19200 KB | Output is correct |
8 | Correct | 19 ms | 19200 KB | Output is correct |
9 | Correct | 15 ms | 19200 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 19200 KB | Output is correct |
2 | Correct | 17 ms | 19200 KB | Output is correct |
3 | Correct | 15 ms | 19200 KB | Output is correct |
4 | Correct | 15 ms | 19200 KB | Output is correct |
5 | Correct | 17 ms | 19200 KB | Output is correct |
6 | Correct | 15 ms | 19200 KB | Output is correct |
7 | Correct | 15 ms | 19200 KB | Output is correct |
8 | Correct | 19 ms | 19200 KB | Output is correct |
9 | Correct | 15 ms | 19200 KB | Output is correct |
10 | Correct | 22 ms | 20096 KB | Output is correct |
11 | Correct | 21 ms | 20224 KB | Output is correct |
12 | Correct | 25 ms | 20480 KB | Output is correct |
13 | Correct | 21 ms | 20096 KB | Output is correct |
14 | Correct | 23 ms | 19968 KB | Output is correct |
15 | Correct | 23 ms | 20304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 781 ms | 124376 KB | Output is correct |
2 | Correct | 516 ms | 81432 KB | Output is correct |
3 | Correct | 552 ms | 87192 KB | Output is correct |
4 | Correct | 624 ms | 95292 KB | Output is correct |
5 | Correct | 648 ms | 96792 KB | Output is correct |
6 | Correct | 742 ms | 103192 KB | Output is correct |
7 | Correct | 785 ms | 125848 KB | Output is correct |
8 | Correct | 568 ms | 81564 KB | Output is correct |
9 | Correct | 530 ms | 87068 KB | Output is correct |
10 | Correct | 543 ms | 95256 KB | Output is correct |
11 | Correct | 574 ms | 96664 KB | Output is correct |
12 | Correct | 641 ms | 104088 KB | Output is correct |
13 | Correct | 524 ms | 80408 KB | Output is correct |
14 | Correct | 528 ms | 80152 KB | Output is correct |
15 | Correct | 505 ms | 80024 KB | Output is correct |
16 | Correct | 516 ms | 80092 KB | Output is correct |
17 | Correct | 758 ms | 124952 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 19200 KB | Output is correct |
2 | Correct | 17 ms | 19200 KB | Output is correct |
3 | Correct | 15 ms | 19200 KB | Output is correct |
4 | Correct | 15 ms | 19200 KB | Output is correct |
5 | Correct | 17 ms | 19200 KB | Output is correct |
6 | Correct | 15 ms | 19200 KB | Output is correct |
7 | Correct | 15 ms | 19200 KB | Output is correct |
8 | Correct | 19 ms | 19200 KB | Output is correct |
9 | Correct | 15 ms | 19200 KB | Output is correct |
10 | Correct | 22 ms | 20096 KB | Output is correct |
11 | Correct | 21 ms | 20224 KB | Output is correct |
12 | Correct | 25 ms | 20480 KB | Output is correct |
13 | Correct | 21 ms | 20096 KB | Output is correct |
14 | Correct | 23 ms | 19968 KB | Output is correct |
15 | Correct | 23 ms | 20304 KB | Output is correct |
16 | Correct | 781 ms | 124376 KB | Output is correct |
17 | Correct | 516 ms | 81432 KB | Output is correct |
18 | Correct | 552 ms | 87192 KB | Output is correct |
19 | Correct | 624 ms | 95292 KB | Output is correct |
20 | Correct | 648 ms | 96792 KB | Output is correct |
21 | Correct | 742 ms | 103192 KB | Output is correct |
22 | Correct | 785 ms | 125848 KB | Output is correct |
23 | Correct | 568 ms | 81564 KB | Output is correct |
24 | Correct | 530 ms | 87068 KB | Output is correct |
25 | Correct | 543 ms | 95256 KB | Output is correct |
26 | Correct | 574 ms | 96664 KB | Output is correct |
27 | Correct | 641 ms | 104088 KB | Output is correct |
28 | Correct | 524 ms | 80408 KB | Output is correct |
29 | Correct | 528 ms | 80152 KB | Output is correct |
30 | Correct | 505 ms | 80024 KB | Output is correct |
31 | Correct | 516 ms | 80092 KB | Output is correct |
32 | Correct | 758 ms | 124952 KB | Output is correct |
33 | Correct | 724 ms | 93276 KB | Output is correct |
34 | Correct | 364 ms | 59096 KB | Output is correct |
35 | Correct | 716 ms | 85116 KB | Output is correct |
36 | Correct | 734 ms | 96536 KB | Output is correct |
37 | Correct | 722 ms | 85916 KB | Output is correct |
38 | Correct | 737 ms | 93080 KB | Output is correct |
39 | Correct | 679 ms | 77208 KB | Output is correct |
40 | Correct | 836 ms | 93720 KB | Output is correct |
41 | Correct | 711 ms | 86808 KB | Output is correct |
42 | Correct | 717 ms | 95896 KB | Output is correct |
43 | Correct | 795 ms | 86036 KB | Output is correct |
44 | Correct | 723 ms | 86168 KB | Output is correct |
45 | Correct | 665 ms | 77464 KB | Output is correct |
46 | Correct | 576 ms | 77080 KB | Output is correct |
47 | Correct | 495 ms | 80280 KB | Output is correct |
48 | Correct | 501 ms | 80280 KB | Output is correct |
49 | Correct | 498 ms | 80280 KB | Output is correct |
50 | Correct | 483 ms | 80152 KB | Output is correct |
51 | Correct | 787 ms | 93592 KB | Output is correct |
52 | Correct | 790 ms | 93524 KB | Output is correct |