제출 #845828

#제출 시각아이디문제언어결과실행 시간메모리
845828Marco_Escandon수천개의 섬 (IOI22_islands)C++17
8.40 / 100
57 ms12632 KiB
#include<bits/stdc++.h> using namespace std; #include <vector> typedef int ll; #include <variant> #include <vector> vector<ll> cad[100001]; ll v[100001]={ }; ll v2[100001]={}; ll pi=0; ll pl=0; void sol(ll node, ll p) { if(pl==1) return ; if(v[node]!=0) { pi=node; v[node]=p; pl=1; return ; } if(v2[node]!=0) return; v2[node]=1; v[node]=p; for(auto i:cad[node]) { sol(i,node); } if(pi==0) { v[node]=0; } } std::variant<bool, std::vector<int>> find_journey(int n, int m, std::vector<int> U, std::vector<int> V) { map<pair<ll,ll>,ll> mapa; for(int i=0; i<m; i++) if(i%2==0) { cad[U[i]+1].push_back(V[i]+1); mapa[{U[i]+1,V[i]+1}]=i; } sol(1,-1); if(pi==0) { return false; } ll p=pi; vector<ll> st; st.push_back(p); p=v[p]; while(p!=pi) { st.push_back(p); p=v[p]; } st.push_back(p); //cout<<st.size()<<"\n"; reverse(st.begin(),st.end()); vector<ll> sol,s2,sol2; for(int i=0; i<st.size()-1; i++) { sol.push_back(mapa[{st[i],st[i+1]}]); s2.push_back(mapa[{st[i],st[i+1]}]); } reverse(sol.begin(),sol.end()); for(int i=0; i<st.size()-1; i++) { sol2.push_back(mapa[{st[i],st[i+1]}]+1); s2.push_back(mapa[{st[i],st[i+1]}]+1); } reverse(sol2.begin(),sol2.end()); for(auto i:sol) s2.push_back(i); for(auto i:sol2) s2.push_back(i); return s2; }

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