제출 #630923

#제출 시각아이디문제언어결과실행 시간메모리
630923garam1732수천개의 섬 (IOI22_islands)C++17
컴파일 에러
0 ms0 KiB
#include "islands.h" #include <iostream> #include <variant> #include <vector> #include <algorithm> #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]; int x = -1; void dfs(int here) { visited[here] = true; //cout << here << endl; for(pi there : adj[here]) { if(visited[there.ff]) { v.push_back(there); x = there.ff; return; } v.push_back(there); dfs(there.ff); if(x != -1) return; 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.insert(pi(U[i], V[i])); } 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:12:1: error: 'map' does not name a type
   12 | map<pi, int> m;
      | ^~~
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:42:12: error: 'm' was not declared in this scope
   42 |         if(m.find(pi(U[i], V[i])) == m.end()) {
      |            ^
islands.cpp:46:9: error: 'm' was not declared in this scope
   46 |         m.insert(pi(U[i], V[i]));
      |         ^
islands.cpp:54: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]
   54 |     for(i = 0; i < v.size(); i++) if(v[i].ff == x) break;
      |                ~~^~~~~~~~~~
islands.cpp:58: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]
   58 |     for(int j = i+1; j < v.size(); j++) ans.push_back(v[j].ss);
      |                      ~~^~~~~~~~~~
islands.cpp:59: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]
   59 |     for(int j = i+1; j < v.size(); j++) ans.push_back(v[j].ss^1);
      |                      ~~^~~~~~~~~~