제출 #872631

#제출 시각아이디문제언어결과실행 시간메모리
872631lighton열쇠 (IOI21_keys)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define all(v) (v).begin(), (v).end() using namespace std; using pi = pair<int,int>; struct CC{ int grp[300001]; int fi(int x){ if(grp[x] == x) return x; else return grp[x] = fi(grp[x]); } void un(int x, int y){ x = fi(x); y = fi(y); assert(x!=y); grp[x] = y; } } cc; vector<int> R,U,V,C; struct CYCLES{ int grp[300001]; int siz[300001]; int toward[300001]; set<int> components[300001]; set<int> colors[300001]; map<int, vector<int> > remainedge[300001]; queue<int> remaincolor[300001]; int fi(int x){ if(grp[x] == x) return x; else return grp[x] = fi(grp[x]); } void un(int x, int y){ x = fi(x); y = fi(y); assert(x!=y); if(siz[x] > siz[y]) swap(x,y); siz[y] += siz[x]; for(auto &i :components[x]){ components[y].insert(i); } for(auto &i :colors[x]){ if(colors[y].find(i) == colors[y].end()) { colors[y].insert(i); } } for(auto &i : colors[y]) remaincolor[y].push(i); for(auto &i : remainedge[x]){ if(i.second.size() && colors[y].find(i.first) != colors[y].end()) remaincolor[y].push(i.first); while(i.second.size()){ remainedge[y][i.first].push_back(i.second.front()); i.second.pop_back(); } } grp[x] = y; toward[y] = -1; } void findedge(int x){ x=fi(x); toward[x] = -1; while(remaincolor[x].size()){ int i = remaincolor[x].front(); for(auto j: remainedge[x][i]){ if(components[x].find(j) == components[x].end()) toward[x] = j; if(toward[x] != -1) break; } if(toward[x] != -1) break; remaincolor[x].pop(); } } } cycles; int N,M; vector<pi> adj[300001]; int chk[300001]; vector<pi> candidate; int ans = 1e9; std::vector<int> find_reachable(std::vector<int> r, std::vector<int> u, std::vector<int> v, std::vector<int> c) { N = r.size(); M = u.size(); R=r;U=u;V=v;C=c; for(int i = 0; i<M; i++){ adj[U[i]].push_back({V[i],C[i]}); adj[V[i]].push_back({U[i],C[i]}); } //init for(int i = 0; i<N; i++){ cc.grp[i] = i; cycles.grp[i] = i; } for(int i = 0; i<N; i++){ cycles.toward[i] = -1; cycles.components[i].insert(i); cycles.colors[i].insert(R[i]); cycles.remaincolor[i].push(R[i]); for(auto &j : adj[i]){ cycles.remainedge[i][j.second].push(j.first); cycles.siz[i]++; } cycles.findedge(i); while(cycles.toward[cycles.fi(i)] != -1 && cc.fi(cycles.toward[cycles.fi(i)]) == cc.fi(i)){ cycles.un(i,cycles.toward[cycles.fi(i)]); cycles.findedge(i); } if(cycles.toward[cycles.fi(i)] == -1){ int tmp = cycles.components[cycles.fi(i)].size(); for(int j : cycles.components[cycles.fi(i)]) candidate.push_back({j,tmp}); ans = min(ans,tmp); } else{ cc.un(cycles.toward[cycles.fi(i)],i); } } std::vector<int> ret(N, 0); for(auto &[i,j] : candidate){ if(j==ans) ret[i] = 1; } return ret; }

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

keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:96:44: error: 'std::map<int, std::vector<int> >::mapped_type' {aka 'class std::vector<int>'} has no member named 'push'
   96 |             cycles.remainedge[i][j.second].push(j.first);
      |                                            ^~~~