제출 #1119662

#제출 시각아이디문제언어결과실행 시간메모리
1119662vjudge1어르신 집배원 (BOI14_postmen)C++17
100 / 100
493 ms86248 KiB
#include<bits/stdc++.h> using namespace std; #define task "task" #define ii pair<int,int> #define fi first #define se second #define int long long #define ll long long #define ld double #define mp make_pair #define lg2 30 #define iii pair<int,ii> #define iiii pair<ii,ii> #define fii fi.fi #define fis fi.se3 #define sfi se.fi #define see se.se #define base 29 int dx[]={0LL,0LL,1,-1,1,1,-1,-1}; int dy[]={1,-1,0LL,0LL,1,-1,1,-1}; const int maxn=1e6+1; const int mod=1e9+7; int n,in[maxn],out[maxn],m,used_edge[maxn]; vector<int>ans; vector<ii>a[maxn]; list<int> euler_walk(int u) { list<int> ans; ans.push_back(u); while (!a[u].empty()) { int v = a[u].back().fi; int eid = a[u].back().se; a[u].pop_back(); if (used_edge[eid]) continue; used_edge[eid] = true; u = v; ans.push_back(u); } for (auto it = ++ans.begin(); it != ans.end(); ++it) { auto t = euler_walk(*it); t.pop_back(); ans.splice(it, t); } return ans; } int pos[maxn]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout);} cin>>n>>m; for(int i=1;i<=m;i++) { int u,v; cin>>u>>v; a[u].push_back({v,i}); a[v].push_back({u,i}); } list<int>ans=euler_walk(1); // for(int x:ans)cout<<x<<" "; // cout<<'\n'; stack<int>s; for(auto x:ans) { if(pos[x]==0)pos[x]=1; else { while(true) { int t=s.top();s.pop(); pos[t]=0; cout<<t<<" "; if(t==x)break; } cout<<'\n'; } pos[x]=1; s.push(x); } cerr <<endl<< "TIME : " << clock() * 0.001 << "s" << endl ; }

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

postmen.cpp: In function 'int main()':
postmen.cpp:50:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
postmen.cpp:51:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |     freopen(task".out","w",stdout);}
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...