제출 #1037374

#제출 시각아이디문제언어결과실행 시간메모리
1037374vjudge1어르신 집배원 (BOI14_postmen)C++17
0 / 100
1101 ms215152 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define pld pair<ld, ld> #define pb push_back #define fi first #define se second #define debug(x) cout << #x << " => " << x << endl #define all(x) x.begin(),x.end() vector<int> adj[500010]; bool vis[500010]; priority_queue<int> pq[500010]; stack<int> st; void dfs(int u,int p) { // debug(u); if(vis[u]) { int prev=u; while(st.top()!=u) { cout<<st.top()<<' '; pq[prev].push(st.top()); pq[st.top()].push(prev); prev=st.top(); vis[st.top()]=0; st.pop(); } pq[prev].push(st.top()); pq[st.top()].push(prev); cout<<st.top()<<'\n'; return; } st.push(u); vis[u]=1; while(!pq[u].empty() && pq[u].top()==adj[u].back()) { pq[u].pop(); adj[u].pop_back(); } for(int i=adj[u].size()-1;i>=0;i--) { // debug(adj[u][i]); while(!pq[u].empty() && pq[u].top()==adj[u].back()) { pq[u].pop(); adj[u].pop_back(); } if(i<adj[u].size() && adj[u][i]!=p) { // debug(adj[u][i]); // debug(p); dfs(adj[u][i],u); while(!pq[u].empty() && pq[u].top()==adj[u].back()) { pq[u].pop(); adj[u].pop_back(); } if(st.top()!=u) return; } } st.pop(); vis[u]=0; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,m;cin>>n>>m; for(int i=0;i<m;i++) { int u,v;cin>>u>>v; adj[u].pb(v); adj[v].pb(u); } for(int i=1;i<=n;i++) sort(all(adj[i])); for(int i=1;i<=n;i++) { while(!adj[i].empty()) dfs(i,-1); } return 0; }

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

postmen.cpp: In function 'void dfs(int, int)':
postmen.cpp:55:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   if(i<adj[u].size() && adj[u][i]!=p)
      |      ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...