# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
805958 | 2023-08-04T03:23:11 Z | LIF | 늑대인간 (IOI18_werewolf) | C++14 | 607 ms | 72420 KB |
#include "werewolf.h" #include<vector> #include<bits/stdc++.h> #include<queue> using namespace std; int pos[300005]; int ind[300005]; int id[300005]; int val[300005]; vector<int> ans; vector<int> vv[300005]; int stmin[200005][23]; int stmax[200005][23]; void dfs(int now,int num) { id[now] = num; val[num] = now; for(int i=0;i<vv[now].size();i++) { int to = vv[now][i]; if(id[to] == 0)dfs(to,num+1); } } int checkmin(int x,int y) { int len = log(y-x+1) / log(2); return min(stmin[x][len],stmin[y-(1<<(len))][len]); } int checkmax(int x,int y) { int len = log(y-x+1) / log(2); return max(stmax[x][len],stmax[y-(1<<len)][len]); } vector<int> check_validity(int N, std::vector<int> X, std::vector<int> Y, std::vector<int> S, std::vector<int> E, std::vector<int> L, std::vector<int> R) { for(int i=0;i<X.size();i++) { ind[X[i]]++;ind[Y[i]]++; vv[X[i]].push_back(Y[i]); vv[Y[i]].push_back(X[i]); } for(int i=0;i<N;i++) { if(ind[i] != 1)continue; dfs(i,0); stmin[i][0] = val[i]; stmax[i][0] = val[i]; break; } for(int i=1;i<20;i++) { for(int j=0;j+ (1<<i) < N;j++) { stmin[j][i] = min(stmin[j][i-1],stmin[j+(1<<(i-1))][i-1]); stmax[j][i] = max(stmax[j][i-1],stmax[j+(1<<(i-1))][i-1]); } } for(int i=0;i<S.size();i++) { int xx = id[S[i]]; int yy = id[E[i]]; if(xx <= yy) { int ll = xx;int rr = yy; int last1 = xx; int last2 = yy; while(ll <= rr) { int mid = (ll+rr)>>1; if(checkmin(xx,mid) >= L[i]) { last1 = mid; ll = mid + 1; } else rr = mid - 1; } ll = xx;rr = yy; while(ll <= rr) { int mid = (ll+rr)>>1; if(checkmax(mid,yy) <= R[i]) { last2 = mid; rr = mid - 1; } else ll = mid+1; } if(last1 >= last2)ans.push_back(1); else ans.push_back(0); } else { swap(xx,yy); int ll = xx;int rr = yy; int last1 = xx; int last2 = yy; while(ll <= rr) { int mid = (ll+rr)>>1; if(checkmax(xx,mid) <= R[i]) { last1 = mid; ll = mid + 1; } else rr = mid - 1; } ll = xx;rr = yy; while(ll <= rr) { int mid = (ll+rr)>>1; if(checkmin(mid,yy) >= L[i]) { last2 = mid; rr = mid - 1; } else ll = mid+1; } if(last1 >= last2)ans.push_back(1); else ans.push_back(0); } } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 7380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 7380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 607 ms | 72420 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 7380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |