제출 #1022259

#제출 시각아이디문제언어결과실행 시간메모리
1022259edogawa_something열쇠 (IOI21_keys)C++17
0 / 100
7 ms14428 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vii; typedef pair<ll,ll> pii; #define pb push_back #define F first #define S second const ll M=2e5+10; ll res[M],root; vector<int>r,c; vector<pair<int,int>>edge[M]; queue<int>q; bool vis[M]; struct DSU{ set<ll>s[M]; ll sz[M],pa[M]; void init(ll x){ for(int i=0;i<x;i++) s[i].clear(),sz[i]=1,pa[i]=i,s[i].insert(r[i]); } ll get(ll x){ if(x==pa[x]) return x; return pa[x]=get(pa[x]); } void unite(ll x,ll y){ x=get(x),y=get(y); if(x==y) return; if(x==get(root)){ for(auto it:s[y]){ if(s[x].find(it)==s[x].end()) q.push(it); } } else if(y==get(root)){ for(auto it:s[x]){ if(s[y].find(it)==s[y].end()) q.push(it); } } if(sz[x]>sz[y]) swap(x,y); for(auto it:s[x]) s[y].insert(it); sz[y]+=sz[x]; pa[x]=y; } }d; bool viss[M]; void process(ll x){ for(int i=0;i<r.size();i++) viss[i]=0; q.push(r[x]); root=x; while(!q.empty()){ ll x=q.front(); q.pop(); if(viss[x]) continue; viss[x]=1; for(auto [u,v]:edge[x]){ d.unite(u,v); } } } std::vector<int> find_reachable(std::vector<int> rr, std::vector<int> u, std::vector<int> v, std::vector<int> cc) { r=rr,c=cc; for(int i=0;i<u.size();i++){ edge[c[i]].pb({u[i],v[i]}); } for(int i=0;i<r.size();i++){ d.init(r.size()); for(int i=0;i<r.size();i++) vis[i]=0; process(i); res[i]=d.sz[d.get(i)]; } vector<int>ans(r.size()); ll z=*min_element(res,res+r.size()); cout<<ans.size()<<endl; for(int i=0;i<r.size();i++){ ans[i]=(res[i]==z); } return ans; }

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

keys.cpp: In function 'void process(ll)':
keys.cpp:54:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |  for(int i=0;i<r.size();i++)
      |              ~^~~~~~~~~
keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:71:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |  for(int i=0;i<u.size();i++){
      |              ~^~~~~~~~~
keys.cpp:74:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |  for(int i=0;i<r.size();i++){
      |              ~^~~~~~~~~
keys.cpp:76:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |   for(int i=0;i<r.size();i++)
      |               ~^~~~~~~~~
keys.cpp:84:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |  for(int i=0;i<r.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...
#Verdict Execution timeMemoryGrader output
Fetching results...