제출 #630939

#제출 시각아이디문제언어결과실행 시간메모리
630939garam1732수천개의 섬 (IOI22_islands)C++17
24 / 100
110 ms12552 KiB
#include "islands.h" #include <iostream> #include <variant> #include <vector> #include <algorithm> #include <map> #define ff first #define ss second using namespace std; typedef pair<int, int> pi; map<pi, int> m; vector<pi> adj[100100]; vector<pi> v; vector<int> ans; bool visited[100100], chk[100100]; int x = -1; void dfs(int here) { //cout << here << endl; for(pi there : adj[here]) { if(visited[there.ff]) { v.push_back(there); x = there.ff; return; } if(chk[there.ff]) continue; visited[there.ff] = true; chk[there.ff] = true; v.push_back(there); dfs(there.ff); if(x != -1) return; visited[there.ff] = false; v.pop_back(); } } vector<int> em; //vector<int> find_journey( std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { for(int i = 0; i < M; i+=2) { if(m.find(pi(U[i], V[i])) == m.end()) { adj[U[i]].push_back(pi(V[i], i)); } //adj[V[i]].push_back(pi(U[i], i)); m[pi(U[i], V[i])] = 1; } visited[0] = chk[0] = true; dfs(0); if(x == -1) return false; int i; for(i = 0; i < v.size(); i++) if(v[i].ff == x) break; if(i == (int)v.size()-1) i = -1; for(int j = 0; j <= i; j++) ans.push_back(v[j].ss); for(int j = i+1; j < v.size(); j++) ans.push_back(v[j].ss); for(int j = i+1; j < v.size(); j++) ans.push_back(v[j].ss^1); for(int j = (int)v.size()-1; j > i; j--) ans.push_back(v[j].ss); for(int j = (int)v.size()-1; j > i; j--) ans.push_back(v[j].ss^1); for(int j = i; j >= 0; j--) ans.push_back(v[j].ss); return ans; // std::vector<int> v, w; // for(int i = 0; i < M; i++) { // if(U[i] == 0) v.push_back(i); // else w.push_back(i); // } // // if(v.size() < 2 || w.size() < 1) { // return em; // //return false; // } // std::vector<int> ans; // ans.push_back(v[0]); // ans.push_back(w[0]); // ans.push_back(v[1]); // ans.push_back(v[0]); // ans.push_back(w[0]); // ans.push_back(v[1]); // return ans; }

컴파일 시 표준 에러 (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:58:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(i = 0; i < v.size(); i++) if(v[i].ff == x) break;
      |                ~~^~~~~~~~~~
islands.cpp:62:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int j = i+1; j < v.size(); j++) ans.push_back(v[j].ss);
      |                      ~~^~~~~~~~~~
islands.cpp:63:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(int j = i+1; j < v.size(); j++) ans.push_back(v[j].ss^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...