Submission #423012

#TimeUsernameProblemLanguageResultExecution timeMemory
423012albertolg101Simurgh (IOI17_simurgh)C++17
0 / 100
3052 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 = 0; vector<int> vans, perm(n); for(int i = 0 ; i < n ; i++) perm[i] = i; function<void(int)> dfs = [&](int nod) { nextNod++; //cout << nod << ' ' << perm[nextNod] << endl ; while(nextNod < perm.size() and g[nod][perm[nextNod]] != -1) { vans.push_back(g[nod][perm[nextNod]]); dfs(perm[nextNod]); //cout << nod << ' ' << perm[nextNod] << endl ; } }; do { vans.clear(); nextNod = 0; dfs(perm[0]); //print(perm); //cout << vans.size() << " - " ; //print(vans); if(vans.size() == n - 1 and count_common_roads(vans) == n - 1) return vans; } while(next_permutation(perm.begin(), perm.end())); while(true); }

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:36:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   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:54:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |   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...