제출 #629016

#제출 시각아이디문제언어결과실행 시간메모리
629016hy_1열쇠 (IOI21_keys)C++17
컴파일 에러
0 ms0 KiB
#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; const int mx = 300001; #define int long long vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { vector<vector<pair<int , int > > > adj(mx); for(int i=0; i <u.size(); i++){ pair<int, int> vv; vv.first = v[i]; vv.second = c[i]; adj[u[i]].push_back(vv); vv.first = u[i]; vv.second = c[i]; adj[v[i]].push_back(vv); } int n = r.size(); vector<int> ans(n , 0); vector<int> level(n); for(int i = 0; i <n; i++){ int source = i; stack<int> st; st.push(source); vector<int> stock; int cnt= 1; stock.push_back(r[source]); // st.push(r[source]); vector<int> visited(mx , false); while(!st.empty()){ int cur = st.top(); st.pop(); visited[cur] = true; for(pair<int , int> j : adj[cur]){ if(count(stock.begin() , stock.end() , j.second) != 0 && visited[j.first] == false){ visited[j.first] = true; st.push(j.first); stock.push_back(r[j.first]); cnt++; } } } level[i] = cnt; } int min = *min_element(level.begin() , level.end()); for(int i =0; i<ans.size(); i++){ if(level[i] == min){ ans[i] = 1; }else{ ans[i] = 0; } } return ans; } /* #1 4 0 1 1 2 5 0 0 1 1 3 1 2 2 3 1 0 0 1 0 2 #2 3 0 0 0 1 0 1 0 #3 7 0 1 1 2 2 1 2 10 0 0 1 1 2 3 3 4 4 5 1 2 2 3 3 4 5 5 6 6 0 0 1 0 0 1 2 0 2 1 */ // int main(){ // int n; cin >> n; // vector<int> r(n); // for(int &i : r) cin >> i; // int m; cin >> m; // vector<int> u(m); // vector<int> v(m); // for(int &i : u) cin >> i; // for(int &i : v) cin >> i; // vector<int> c(m); // for(int &i : c) cin >> i; // for(int i =0; i <n; i++){ // vector<int> ans = find_reachable(r , u , v, c); // for(int i :ans){ // cout << i << " "; // } // cout << endl; // } // return 0; // }

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

keys.cpp: In function 'std::vector<long long int> find_reachable(std::vector<long long int>, std::vector<long long int>, std::vector<long long int>, std::vector<long long int>)':
keys.cpp:45:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  for(int i=0; i <u.size(); i++){
      |               ~~^~~~~~~~~
keys.cpp:84:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |  for(int i  =0; i<ans.size(); i++){
      |                 ~^~~~~~~~~~~
/usr/bin/ld: /tmp/ccOz0l45.o: in function `main':
grader.cpp:(.text.startup+0x30a): undefined reference to `find_reachable(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status