이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <cmath>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <unordered_map>
using namespace std;
int dfs(int source , vector<int> &c , int vv , vector<vector<pair<int , int > > > &adj){
int cnt = 0;
stack<int> st;
st.push(source);
set<int> stock;
stock.insert(c[source]);
vector<int> visited(vv , false);
// int cnt = 0;
while(!st.empty()){
int cur = st.top();
st.pop();
visited[cur] = true;
for(pair<int , int > i : adj[cur]){
if(visited[i.first] == false && (count(stock.begin() , stock.end() , i.second)) != 0){
st.push(i.first);
visited[i.first] = true;
cnt++;
}
}
}
return cnt;
}
vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) {
vector<vector< pair<int, int > > > adj(r.size());
for(int j=0; j<u.size(); j++){
pair<int , int> you;
you.first = v[j];
you.second = c[j];
adj[u[j]].push_back(you);
pair<int , int> rr;
rr.first = u[j];
rr.second = c[j];
adj[v[j]].push_back(rr);
}
vector<int> mx(r.size());
for(int i = 0; i <r.size(); i++){
mx[i] = dfs(i , c , r.size() , adj);
}
int y = *min_element(mx.begin() , mx.end());
vector<int> ans(r.size() , 0);
for(int i=0; i <mx.size(); i++){
if(mx[i] == y) ans[i] = 1;
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:65:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | for(int j=0; j<u.size(); j++){
| ~^~~~~~~~~
keys.cpp:76:20: 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:82:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
82 | for(int i=0; i <mx.size(); i++){
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |