제출 #1013619

#제출 시각아이디문제언어결과실행 시간메모리
1013619MarwenElarbi늑대인간 (IOI18_werewolf)C++17
0 / 100
92 ms28076 KiB
#include <bits/stdc++.h> #include "werewolf.h" using namespace std; #define fi first #define se second #define ll long long #define pb push_back #define ii pair<int,int> const int nax=3e3+5; vector<int> adj[nax]; vector<int> mn(nax); vector<int> mx(nax); bool vis[nax]; int n; void min_djikastra(int x){ priority_queue<int,vector<int>,greater<int>> pq; pq.push(x); mn[x]=x; vis[x]=true; while(!pq.empty()){ int node=pq.top(); pq.pop(); for(auto u:adj[node]){ if(vis[u]) continue; vis[u]=true; mn[u]=min(u,mn[node]); pq.push(u); } } } void max_djikastra(int x){ priority_queue<int> pq; pq.push(x); mx[x]=x; vis[x]=true; while(!pq.empty()){ int node=pq.top(); pq.pop(); for(auto u:adj[node]){ if(vis[u]) continue; vis[u]=true; mx[u]=max(u,mx[node]); pq.push(u); } } } std::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) { n=N; for (int i = 0; i < (int)X.size(); ++i) { adj[X[i]].pb(Y[i]); adj[Y[i]].pb(X[i]); } vector<int> ans; int Q=R.size(); for (int i = 0; i < Q; ++i) { for (int j = 0; j < N; ++j) { mn[j]=1e9; mx[j]=-1e9; } memset(vis,0,sizeof vis); min_djikastra(S[i]); memset(vis,0,sizeof vis); max_djikastra(E[i]); pair<int,int> cur={L[i],R[i]}; bool test=false; for (int j = L[i]; j < R[i]+1; ++j) { if(cur.fi<=mn[j]&&mx[j]<=cur.se){ test=true; } if(test) break; }//cout <<endl; ans.pb((test==true ? 1 : 0)); } return ans; } /*namespace { int read_int() { int x; if (scanf("%d", &x) != 1) { fprintf(stderr, "Error while reading input\n"); exit(1); } return x; } } // namespace int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int N = read_int(); int M = read_int(); int Q = read_int(); std::vector<int> X(M), Y(M), S(Q), E(Q), L(Q), R(Q); for (int j = 0; j < M; ++j) { X[j] = read_int(); Y[j] = read_int(); } for (int i = 0; i < Q; ++i) { S[i] = read_int(); E[i] = read_int(); L[i] = read_int(); R[i] = read_int(); } std::vector<int> A = check_validity(N, X, Y, S, E, L, R); for (size_t i = 0; i < A.size(); ++i) { printf("%d\n", A[i]); } return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...