제출 #534765

#제출 시각아이디문제언어결과실행 시간메모리
534765Icebear16열쇠 (IOI21_keys)C++17
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> std::vector<int> adj[2000]; std::vector<bool> visited(2000,false); int k=0; void dfs(int u){ if(visited[u]){ return; }else{ visited[u]=true; k+=1; // std::cout<<u<<" "; } for(int i=0;i<adj[u].size();i++){ 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++){ if(r[i]==0){ // std::cout<<std::endl; 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: In function 'void dfs(int)':
keys.cpp:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i=0;i<adj[u].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:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i=0;i<u.size();i++){
      |              ~^~~~~~~~~
keys.cpp:26:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for(int i=0;i<r.size();i++){
      |              ~^~~~~~~~~
keys.cpp:33:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    for(int j=0;j<r.size();j++){
      |                ~^~~~~~~~~
keys.cpp:39:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(int i=0;i<r.size();i++){
      |              ~^~~~~~~~~
keys.cpp:43:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |  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...