제출 #998881

#제출 시각아이디문제언어결과실행 시간메모리
998881lucascgar어르신 집배원 (BOI14_postmen)C++17
0 / 100
2 ms12124 KiB
#include<bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef pair<long, long> pll; typedef pair<double, double> pdd; /* desde quando vi da ultima vez até quando vejo de novo, deixo ele em ans sozinho */ const int MAXN = 5e5+10; vector<pii> e[MAXN]; vector<int> ans; bool ve[MAXN]; int v[MAXN]; int sk[MAXN]; void dfs(int x){ while (!e[x].empty()){ pii u = e[x].back(); e[x].pop_back(); if (ve[u.second] == 1) continue; ve[u.second] = 1; dfs(u.first); } ans.push_back(x); } void ct(int st){ // cout, then jump sk[st] = max(sk[st], 1); cout << ans[st]; int i = st+sk[st]; while (i<ans.size()){ cout << " " << ans[i]; if (ans[i] == ans[st]){ cout << "\n"; break; } if (!sk[i]) i++; else i += sk[i]; } sk[st] = i-st+1; } int main(){ std::ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; int a, b; for (int i=0;i<m;i++){ cin >> a >> b; e[a].emplace_back(b, i); e[b].emplace_back(a, i); } dfs(1); for (int i=0;i<ans.size();i++){ int x = ans[i]; if (!v[x]){ v[x] = i+1; }else{ ct(v[x]-1); for (int j=v[x]-1;j<=i;j++) v[ans[j]] = 0; v[x] = i+1; } } }

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

postmen.cpp: In function 'void ct(int)':
postmen.cpp:41:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     while (i<ans.size()){
      |            ~^~~~~~~~~~~
postmen.cpp: In function 'int main()':
postmen.cpp:72:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |     for (int i=0;i<ans.size();i++){
      |                  ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...