제출 #837000

#제출 시각아이디문제언어결과실행 시간메모리
837000APROHACK수천개의 섬 (IOI22_islands)C++17
31 / 100
53 ms33820 KiB
#include "islands.h" #include <bits/stdc++.h> #define pb push_back #define ll long long #define ff first #define ss second #include <variant> #include <vector> using namespace std; vector<pair<int, int > >child[5005]; int devuelta[200005]; vector<pair<int, int > > adj[5005]; vector<int>tempRoute; vector<int>rt; bool dfs(int node, int parent){ //cout << " at node " << node << endl; for(int i = 0 ; i < adj[node].size() ; i ++){ if(adj[node][i].ff == parent)continue; child[node].pb(adj[node][i]); } if(child[node].size() >= 2){ int a = child[node][0].ss; int b = devuelta[child[node][0].ss]; int c = child[node][1].ss; int d = devuelta[c]; tempRoute = {a, b, c, d, b, a, d, c}; return true; } for(auto i : child[node]){ if(dfs(i.ff, node)){ rt.pb(i.ss); return true; } } return false; } std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { int cuenta[N][N]; vector<int>parejas[N][N]; for(int i = 0 ; i < N ; i ++){ for(int j = 0 ; j < N ; j ++){ cuenta[i][j] = 0; } } for(int i = 0 ; i < M ; i ++ ){ cuenta[U[i]][V[i]] ++ ; parejas[U[i]][V[i]].pb(i); adj[U[i]].pb({V[i], i}); } if (N == 2) { if(cuenta[0][1] >= 2 and cuenta[1][0] >= 1){ int a = parejas[0][1][0]; int b = parejas[1][0][0]; int c = parejas[0][1][1]; vector<int>ans = {a, b, c, a, b, c}; return ans; } return false; }else{ bool case3 = true; if( M % 2 == 1)case3 = false; if(case3){ for(int i = 0 ; i < M ; i += 2){ if(U[i] != V[i+1] or V[i] != U[i+1] )case3 = false; devuelta[i] = i+1; devuelta[i+1] = i; } } if(!case3){ //cout << "wrong case : " << endl; int a = parejas[0][1][0]; int b = parejas[1][0][0]; int c = parejas[0][2][0]; int d = parejas[2][0][0]; vector<int>ans = {a, b, c, d, b, a, d, c}; return ans; }else{ if(!dfs(0, -1))return false; vector<int>ans = rt; reverse(ans.begin(), ans.end()); for(auto i : tempRoute)ans.pb(i); for(auto i : rt)ans.pb(i); return ans; } } }

컴파일 시 표준 에러 (stderr) 메시지

islands.cpp: In function 'bool dfs(int, int)':
islands.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i = 0 ; i < adj[node].size() ; i ++){
      |                  ~~^~~~~~~~~~~~~~~~~~
#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...