Submission #534761

#TimeUsernameProblemLanguageResultExecution timeMemory
534761Icebear16Keys (IOI21_keys)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> std::vector<int> adj[2000]; std::vector<bool> visited(2000,false); int k=1; void dfs(int u){ if(visited[u]){ return; } visited[u]=true; for(int i=0;i<adj[u].size();i++){ int v=adj[u][i]; k+=1; 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(), 0); 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){ dfs(i); ans[i]=k; k=1; 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]); } for(int i=0;i<r.size();i++){ if(ans[i]==m){ ans[i]=1; }else{ ans[i]=0; } } return ans; }

Compilation message (stderr)

keys.cpp: In function 'void dfs(int)':
keys.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  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:20:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for(int i=0;i<u.size();i++){
      |              ~^~~~~~~~~
keys.cpp:24:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for(int i=0;i<r.size();i++){
      |              ~^~~~~~~~~
keys.cpp:29:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |    for(int j=0;j<r.size();j++){
      |                ~^~~~~~~~~
keys.cpp:35:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for(int i=0;i<r.size();i++){
      |              ~^~~~~~~~~
keys.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  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...