제출 #205333

#제출 시각아이디문제언어결과실행 시간메모리
205333medk늑대인간 (IOI18_werewolf)C++14
컴파일 에러
0 ms0 KiB
#include "werewolf.h" #include <bits/stdc++.h> #define ll long long #define pb push_back #define x first #define y second using namespace std; vector<vector<int>> g(200001); vector<bool> vis(200001); vector<int> ln,pos(200001); void dfs1(int u, int l) { st.insert(u); for(int v:g[u]) { if(v<l || st.count(v)) continue; dfs1(v,l); } } int dfs2(int u, int r) { int ret=st.count(u); vis[u]=1; for(int v:g[u]) { if(v>r || vis[v]) continue; ret|=dfs2(v,r); } return ret; } vector<int> check_validity(int n, vector<int> x, vector<int> y, vector<int> s, vector<int> e, vector<int> l, vector<int> r) { int m=x.size(), q=s.size(); for(int i=0;i<m;i++) g[x[i]].pb(y[i]), g[y[i]].pb(x[i]); if(n<=3000 && m<=6000 && q<=3000) { vector<int> ans; for(int i=0;i<q;i++) { st.clear(); dfs1(s[i],l[i]); for(int j=0;j<n;j++) vis[j]=0; ans.pb(dfs2(e[i],r[i])); } return ans; } int leaf; for(int i=0;i<n;i++) if((int)g[i].size()==1) {leaf=i; break;} while((int)ln.size()<n) { pos[leaf]=(int)ln.size(); ln.pb(leaf); vis[leaf]=1; for(int v:g[leaf]) { if(vis[v]) continue; leaf=v; } } vector<pair<int,int>> L,R; for(int i=0;i<q;i++) L.pb({-l[i],i}), R.pb({r[i],i}); sort(L.begin(),L.end()); sort(R.begin(),R.end()); vector<pair<int,int>> lftmost(q); int ptr=n-1; set<pair<int,int>> st; set<pair<int,int>>::iterator it; for(int i=0;i<q;i++) { while(ptr>=-L[i].x) { int ps=pos[ptr]; it=st.upper_bound({ps,ps}); pair<int,int> p={ps,ps}; if(it!=st.end()) if((*it).x==ps+1) p.y=(*it).y, st.erase(it); it=st.upper_bound({ps,ps}); if((int)st.size()) if(it!=st.begin()) if((*prev(it)).y==ps-1) p.x=(*prev(it)).x, st.erase(prev(it)); st.insert(p); ptr--; } it=prev(st.upper_bound({pos[s[L[i].y]]+1,-1})); lftmost[L[i].y]=*it; } ptr=0; st.clear(); vector<int> ans(q); for(int i=0;i<q;i++) { while(ptr<=R[i].x) { int ps=pos[ptr]; it=st.upper_bound({ps,ps}); pair<int,int> p={ps,ps}; if(it!=st.end()) if((*it).x==ps+1) p.y=(*it).y, st.erase(it); it=st.upper_bound({ps,ps}); if((int)st.size()) if(it!=st.begin()) if((*prev(it)).y==ps-1) p.x=(*prev(it)).x, st.erase(prev(it)); st.insert(p); ptr++; } it=prev(st.upper_bound({pos[e[R[i].y]]+1,-1})); ans[R[i].y]=!((*it).y<lftmost[R[i].y].x || (*it).x>lftmost[R[i].y].y); } return ans; }

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

werewolf.cpp: In function 'void dfs1(int, int)':
werewolf.cpp:17:5: error: 'st' was not declared in this scope
     st.insert(u);
     ^~
werewolf.cpp: In function 'int dfs2(int, int)':
werewolf.cpp:27:13: error: 'st' was not declared in this scope
     int ret=st.count(u);
             ^~
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:46:13: error: 'st' was not declared in this scope
             st.clear();
             ^~
werewolf.cpp:46:13: note: suggested alternative: 's'
             st.clear();
             ^~
             s