제출 #129711

#제출 시각아이디문제언어결과실행 시간메모리
129711Talant늑대인간 (IOI18_werewolf)C++17
0 / 100
297 ms51684 KiB
#include "werewolf.h" #include <bits/stdc++.h> #define a first #define b second #define pb push_back #define mk make_pair #define node pair<int,int> using namespace std; const int NN = (2e5 + 5); const int inf = (1e9 + 7); int n,q,m; int dev[NN]; int l,r; int a[NN],pos[NN],cn; node t[NN * 4],cr; vector <int> ans,g[NN]; node combine(node a,node b) { a.a = max(a.a,b.a); a.b = min(a.b,b.b); return a; } void build (int v = 1,int tl = 1,int tr = n) { if (tl == tr) { t[v].a = t[v].b = a[tl]; } else { int tm = (tl + tr) >> 1; build (v + v,tl,tm); build (v + v + 1,tm + 1,tr); t[v] = combine(t[v + v],t[v + v + 1]); } } node get (int l,int r,int v = 1,int tl = 1,int tr = n) { if (tl > r || tr < l) return {0,inf}; if (l <= tl && tr <= r) return t[v]; int tm = (tl + tr) >> 1; return combine(get(l,r,v + v,tl,tm),get(l,r,v + v + 1,tm + 1,tr)); } vector<int> check_validity(int N, vector<int> X, vector<int> Y,vector<int> S, vector<int> E, vector<int> L, vector<int> R) { n = N,q = S.size(),m = X.size(); for (int i = 0; i < m; i ++) X[i] ++,Y[i] ++; for (int i = 0; i < q; i ++) S[i] ++,E[i] ++,L[i] ++,R[i] ++; if (m == n - 1) { for (int i = 0; i < m; i ++) { g[X[i]].pb(Y[i]); g[Y[i]].pb(X[i]); dev[X[i]] ++; dev[Y[i]] ++; } for (int i = 1; i <= n; i ++) { if (dev[i] == 1 && l == -1) l = i; else if (dev[i] == 1) r = i; } int cur = l; while (cur != r) { a[++cn] = cur; pos[cur] = cn; if (a[cn - 1] != g[cur][0]) cur = g[cur][0]; else cur = g[cur][1]; } a[++cn] = r; build(); for (int i = 0; i < q; i ++) { int aa = S[i],bb = E[i],sl = L[i],sr = R[i]; if (pos[aa] <= pos[bb]) { int lo = pos[aa],hi = pos[bb]; while (hi - lo > 1) { int md = (hi + lo) >> 1; cr = get(pos[aa],md); if (cr.b >= sl) lo = md; else hi = md; } cr = get(pos[aa],hi); if (cr.b >= sl) lo = hi; l = pos[aa],r = pos[bb]; while (r - l > 1) { int md = (r + l) >> 1; cr = get(md,pos[bb]); if (cr.a <= sr) r = md; else l = md; } cr = get(l,pos[bb]); if (cr.a <= sr) r = l; if (r <= lo) ans.pb(1); else ans.pb(0); } else { int lo = pos[aa],hi = pos[bb]; while (hi - lo > 1) { int md = (hi + lo) >> 1; cr = get(pos[aa],md); if (cr.a <= sr) lo = md; else hi = md; } cr = get(pos[aa],hi); if (cr.a <= sr) lo = hi; l = pos[aa],r = pos[bb]; while (r - l > 1) { int md = (r + l) >> 1; cr = get(md,pos[bb]); if (cr.b >= sl) r = md; else l = md; } cr = get(l,pos[bb]); if (cr.b >= sl) r = l; if (r <= lo) ans.pb(1); else ans.pb(0); } } return ans; } }

컴파일 시 표준 에러 (stderr) 메시지

werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:122:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...