Submission #423027

#TimeUsernameProblemLanguageResultExecution timeMemory
423027albertolg101Simurgh (IOI17_simurgh)C++17
0 / 100
6 ms204 KiB
#include <bits/stdc++.h> #include "simurgh.h" using namespace std; using pii = pair<int, int>; void print (vector<int> &ar) { for(auto i: ar) cout << i << ' ' ; cout << endl ; } std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) { vector<vector<int>> g(n, vector<int> (n, -1)); for(int i = 0 ; i < u.size() ; i++) { int a = u[i], b = v[i]; g[a][b] = g[b][a] = i; } int nextNod; vector<int> perm; for(int i = 0 ; i < n ; i++) perm.push_back(i); function<void(int, vector<int>&)> dfs = [&](int nod, vector<int> &vans) { nextNod++; while(nextNod < perm.size() and g[nod][perm[nextNod]] != -1) { vans.push_back(g[nod][perm[nextNod]]); dfs(perm[nextNod], vans); } }; do { nextNod = 0; vector<int> vans; dfs(perm[0], vans); if(vans.size() == n - 1 and count_common_roads(vans) == n - 1) return vans; } while(next_permutation(perm.begin(), perm.end())); return perm; }

Compilation message (stderr)

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:18:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i = 0 ; i < u.size() ; i++)
      |                  ~~^~~~~~~~~~
simurgh.cpp: In lambda function:
simurgh.cpp:34:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   while(nextNod < perm.size() and g[nod][perm[nextNod]] != -1)
      |         ~~~~~~~~^~~~~~~~~~~~~
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:46:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |   if(vans.size() == n - 1 and count_common_roads(vans) == n - 1)
      |      ~~~~~~~~~~~~^~~~~~~~
#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...