제출 #1057852

#제출 시각아이디문제언어결과실행 시간메모리
1057852mychecksedad수천개의 섬 (IOI22_islands)C++17
5 / 100
20 ms9544 KiB
#include "islands.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define en cout << '\n' #define all(x) x.begin(),x.end() #define pii pair<int,int> #define vi vector<int> #define ff first #define ss second const int N = 1e5+10; int n, m; vector<pair<int, int>> g[N]; vector<int> euler, cyc; vector<bool> good, in_euler(N); bool is_cyc = 0; bool dfs(int v, int par, vector<bool> &vis){ vis[v] = 1; euler.pb(v); in_euler[v] = 1; for(auto U: g[v]){ int u = U.ss; if(vis[u] && u != par && in_euler[u]){ euler.pb(u); cyc.pb(u); is_cyc = 1; return 1; } if(good[v] && good[u]){ } if(!vis[u]){ bool ok = dfs(u, v, vis); if(is_cyc) cyc.pb(v); if(ok && v == cyc.back()){ is_cyc = 0; } if(ok) return 1; } } euler.pop_back(); in_euler[v] = 0; return 0; } std::variant<bool, std::vector<int>> find_journey(int nn, int mm, std::vector<int> U, std::vector<int> V) { n=nn, m=mm; vector<vi> C(nn); map<pii, vi> A; good.resize(n); for(int i = 0; i < mm; ++i){ C[U[i]].pb(i); g[U[i]].pb({i, V[i]}); A[{U[i], V[i]}].pb(i); if(A[{U[i], V[i]}].size() > 1) good[U[i]] = good[V[i]] = 1; } for(int i = 1; i < n; ++i){ if(A[{0, i}].size() > 1 && A[{i, 0}].size() > 0){ return vi{A[{0, i}][0], A[{i, 0}][0], A[{0, i}][1], A[{0, i}][0], A[{i, 0}][0], A[{0, i}][1]}; } } // if(!(C[0].size() > 1 && C[1].size() > 0)) return false; vector<bool> vis(n); bool ok = dfs(0, 0, vis); if(!ok) return false; vi res; for(int i = 0; i + 1 < euler.size(); ++i){ res.pb(A[{euler[i], euler[i + 1]}][0]); } reverse(all(cyc)); for(int i = 0; i + 1 < cyc.size(); ++i){ cyc.pb(A[{cyc[i], cyc[i + 1]}][0]); } for(int i = 0; i + 1 < cyc.size(); ++i){ cyc.pb(A[{euler[i], euler[i + 1]}][1]); } reverse(all(res)); for(int i = 0; i + 1 < euler.size(); ++i){ res.pb(A[{euler[i], euler[i + 1]}][0]); } return res; }

컴파일 시 표준 에러 (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:67:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |   for(int i = 0; i + 1 < euler.size(); ++i){
      |                  ~~~~~~^~~~~~~~~~~~~~
islands.cpp:71:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |   for(int i = 0; i + 1 < cyc.size(); ++i){
      |                  ~~~~~~^~~~~~~~~~~~
islands.cpp:74:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |   for(int i = 0; i + 1 < cyc.size(); ++i){
      |                  ~~~~~~^~~~~~~~~~~~
islands.cpp:78:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |   for(int i = 0; i + 1 < euler.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...