제출 #534764

#제출 시각아이디문제언어결과실행 시간메모리
534764Icebear16열쇠 (IOI21_keys)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> std::vector<int> adj[2000]; std::vector<bool> visited(2000,false); int k=0; set<int> s; void dfs(int u){ if(visited[u]){ return; }else{ visited[u]=true; s.insert(r[u]); k+=1; // std::cout<<u<<" "; } for(int i=0;i<adj[u].size();i++){ if(s.count()) int v=adj[u][i]; dfs(v); } } std::vector<int> find_reachable(std::vector<int> r, std::vector<int> u, std::vector<int> v, std::vector<int> c) { std::vector<int> ans(r.size(), 1); for(int i=0;i<u.size();i++){ adj[u[i]].push_back(v[i]); // adj[v[i]].push_back(u[i]); } for(int i=0;i<r.size();i++){ // std::cout<<std::endl; s.insert(r[i]); dfs(i); // std::cout<<k<<std::endl; ans[i]=k; k=0; for(int j=0;j<r.size();j++){ visited[j]=false; } } int m=1000000; for(int i=0;i<r.size();i++){ m=std::min(m,ans[i]); } // return ans; for(int i=0;i<r.size();i++){ if(ans[i]==m){ ans[i]=1; }else{ ans[i]=0; } } return ans; }

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

keys.cpp:6:1: error: 'set' does not name a type; did you mean 'setns'?
    6 | set<int> s;
      | ^~~
      | setns
keys.cpp: In function 'void dfs(int)':
keys.cpp:12:3: error: 's' was not declared in this scope
   12 |   s.insert(r[u]);
      |   ^
keys.cpp:12:12: error: 'r' was not declared in this scope
   12 |   s.insert(r[u]);
      |            ^
keys.cpp:16:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int i=0;i<adj[u].size();i++){
      |              ~^~~~~~~~~~~~~~
keys.cpp:17:6: error: 's' was not declared in this scope
   17 |   if(s.count())
      |      ^
keys.cpp:18:7: warning: unused variable 'v' [-Wunused-variable]
   18 |   int v=adj[u][i];
      |       ^
keys.cpp:19:7: error: 'v' was not declared in this scope
   19 |   dfs(v);
      |       ^
keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:25:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(int i=0;i<u.size();i++){
      |              ~^~~~~~~~~
keys.cpp:29:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for(int i=0;i<r.size();i++){
      |              ~^~~~~~~~~
keys.cpp:31:3: error: 's' was not declared in this scope
   31 |   s.insert(r[i]);
      |   ^
keys.cpp:36:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for(int j=0;j<r.size();j++){
      |               ~^~~~~~~~~
keys.cpp:41:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i=0;i<r.size();i++){
      |              ~^~~~~~~~~
keys.cpp:45:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  for(int i=0;i<r.size();i++){
      |              ~^~~~~~~~~