제출 #1050273

#제출 시각아이디문제언어결과실행 시간메모리
1050273christinelynn어르신 집배원 (BOI14_postmen)C++17
55 / 100
58 ms13120 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n, m; vector<pair<int, int>> adj[100005]; int ind[100005]; bool ya[100005], vis[100005]; vector<pair<int, int>> star; void dfs(int a) { stack<int> s; s.push(a); vis[a] = true; while(true) { int b = s.top(); while(true) { if(ind[b] == adj[b].size()) { break; } int c = adj[b][ind[b]].second; if(ya[c] == true) { ind[b]++; } else { break; } } if(ind[b] == adj[b].size()) { //cout << b << "\n"; if(s.size() > 1) { while(!s.empty()) { cout << s.top() << " "; vis[s.top()] = false; s.pop(); } cout << "\n"; } else { vis[b] = false; } break; } int nxt = adj[b][ind[b]].first, jo = adj[b][ind[b]].second; ind[b]++; ya[jo] = true; if(vis[nxt] == true) { cout << nxt << " "; while(s.top() != nxt) { cout << s.top() << " "; vis[s.top()] = false; s.pop(); } cout << "\n"; } else { vis[nxt] = true; s.push(nxt); } } } signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); cin >> n >> m; for(int i = 0; i < m; i++) { int y, z; cin >> y >> z; star.push_back({y, z}); adj[y].push_back({z, i}); adj[z].push_back({y, i}); } for(int i = 0; i < m; i++) { if(ya[i] == false) { ya[i] = true; //cout << i << "\n"; dfs(star[i].first); } } }

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

postmen.cpp: In function 'void dfs(long long int)':
postmen.cpp:17:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |       if(ind[b] == adj[b].size()) {
      |          ~~~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:27:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     if(ind[b] == adj[b].size()) {
      |        ~~~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...