제출 #295435

#제출 시각아이디문제언어결과실행 시간메모리
295435eohomegrownapps늑대인간 (IOI18_werewolf)C++14
0 / 100
1743 ms30968 KiB
#include "werewolf.h" #include <bits/stdc++.h> using namespace std; vector<int> l; vector<int> r; int n,q; int sqrtn; vector<vector<int>> adjlist; bool comp(int a, int b){ if (l[a]/sqrtn == l[b]/sqrtn){ return r[a]<r[b]; } else { return l[a]<l[b]; } } 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) { q = s.size(); l=L;r=R;n=N; sqrtn=sqrt(n); vector<int> inds(q); for (int i = 0; i<q; i++){ inds[i]=i; } sort(inds.begin(),inds.end(),comp); adjlist.resize(n); for (int i = 0; i<x.size(); i++){ //cout<<x[i]<<' '<<y[i]<<endl; adjlist[x[i]].push_back(y[i]); adjlist[y[i]].push_back(x[i]); } int start = -1; for (int i = 0; i<n; i++){ if (adjlist[i].size()==1){ start=i; break; } } int cur = start; int pre = -1; int ptr = 0; vector<int> ind2pop(n); vector<int> pop2ind(n); do { ind2pop[ptr]=cur; ind2pop[cur]=ptr; if (adjlist[cur][0]==pre){ pre=cur; cur=adjlist[cur][1]; } else { pre=cur; cur=adjlist[cur][0]; } ptr++; } while (adjlist[cur].size()!=1); vector<int> ans(q); int lv = 0; int rv = 0; set<int> lvals; set<int> rvals; for (int i = 1; i<n; i++){ rvals.insert(pop2ind[i]); } lvals.insert(-1); lvals.insert(n); rvals.insert(-1); rvals.insert(n); for (int i = 0; i<q; i++){ while (lv!=l[inds[i]]){ if (lv<l[inds[i]]){ lvals.insert(pop2ind[lv]); lv++; } else { lvals.erase(pop2ind[lv]); lv--; } } while (rv!=r[inds[i]]){ if (rv<r[inds[i]]){ rvals.insert(pop2ind[rv]); rv++; } else { rvals.erase(pop2ind[rv]); rv--; } } int ls = *(prev(lvals.lower_bound(s[inds[i]]),1)); int le = *(lvals.lower_bound(s[inds[i]])); int rs = *(prev(rvals.lower_bound(e[inds[i]]),1)); int re = *(rvals.lower_bound(e[inds[i]])); if (le<rs||re<ls){ ans[i]=0; } else { ans[i]=1; } } 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:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int i = 0; i<x.size(); i++){
      |                     ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...