Submission #628520

#TimeUsernameProblemLanguageResultExecution timeMemory
628520SortingThousands Islands (IOI22_islands)C++17
10 / 100
33 ms5272 KiB
#include "islands.h" #include <variant> #include <vector> #include <algorithm> #include <cmath> using namespace std; std::variant<bool, std::vector<int>> find_journey( int n, int m, std::vector<int> u, std::vector<int> v) { if(n == 2){ vector<int> cnt[2]{}; for(int i = 0; i < u.size();++i){ cnt[u[i]].push_back(i); } if(cnt[0].size() >= 2 && cnt[1].size() >= 1){ return vector<int>{cnt[0][0], cnt[1][0], cnt[0][1], cnt[0][0], cnt[1][0], cnt[0][1]}; } return false; } vector<vector<pair<int, int>>> adj(n); for(int i = 0; i < m; ++i){ adj[u[i]].push_back({v[i], i}); // adj[v[i]].push_back({u[i], i}); } vector<int> ans; ans.push_back(adj[0][0].second); int x = adj[0][0].first; for(int j = 0; j < adj[x].size(); ++j){ if(adj[x][j].first == 0){ ans.push_back(adj[x][j].second); break; } } ans.push_back(adj[0][1].second); x = adj[0][1].first; for(int j = 0; j < adj[x].size(); ++j){ if(adj[x][j].first == 0){ ans.push_back(adj[x][j].second); break; } } ans.push_back(ans[1]); ans.push_back(ans[0]); ans.push_back(ans[3]); ans.push_back(ans[2]); return ans; }

Compilation message (stderr)

islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:14:26: 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 < u.size();++i){
      |                        ~~^~~~~~~~~~
islands.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int j = 0; j < adj[x].size(); ++j){
      |                    ~~^~~~~~~~~~~~~~~
islands.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int j = 0; j < adj[x].size(); ++j){
      |                    ~~^~~~~~~~~~~~~~~
#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...