# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
805958 | LIF | 늑대인간 (IOI18_werewolf) | C++14 | 607 ms | 72420 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |