제출 #745352

#제출 시각아이디문제언어결과실행 시간메모리
745352Markomafko972어르신 집배원 (BOI14_postmen)C++14
55 / 100
516 ms180044 KiB
#include <bits/stdc++.h> #define X first #define Y second #define pb push_back #define pii pair<int, int> typedef long long ll; using namespace std; const int MOD = 1e9 + 7; const ll INF = 1e18; const int OFF = (1 << 20); int n, m, a, b; vector<int> s[500005]; unordered_map<int, int> mp[500005]; vector<int> v; vector<int> ost; int bio[500005]; vector<int> rj[500005]; int sol = 0; void dfs(int x) { while (s[x].size() > 0) { while (s[x].size() > 0 && mp[min(x, s[x].back())][max(x, s[x].back())] == 1) s[x].pop_back(); if (s[x].size() == 0) break; int sus = s[x].back(); s[x].pop_back(); mp[min(x, sus)][max(x, sus)] = 1; dfs(sus); } v.push_back(x); } int main () { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a >> b; s[a].push_back(b); s[b].push_back(a); } dfs(1); reverse(v.begin(), v.end()); int kol = 0; for (int i = 0; i < v.size(); i++) { if (bio[v[i]]) { rj[sol].push_back(v[i]); while (ost.back() != v[i]) { rj[sol].push_back(ost.back()); bio[ost.back()]--; ost.pop_back(); } kol += rj[sol].size(); sol++; } else { bio[v[i]] = 1; ost.push_back(v[i]); } } if (kol != m) assert(0); for (int i = 0; i < sol; i++) { for (int j = 0; j < rj[i].size(); j++) cout << rj[i][j] << " "; cout << "\n"; } return 0; }

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

postmen.cpp: In function 'int main()':
postmen.cpp:49:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for (int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
postmen.cpp:68:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |   for (int j = 0; j < rj[i].size(); j++) cout << rj[i][j] << " ";
      |                   ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...