제출 #1119663

#제출 시각아이디문제언어결과실행 시간메모리
1119663vjudge1어르신 집배원 (BOI14_postmen)C++17
0 / 100
77 ms54064 KiB
#include<bits/stdc++.h> #define str string #define task "strdel" #define ii pair<int,int> #define iii pair<int,ii> #define iv pair<ii,ii> #define se second #define fi first #define ffi fi.fi #define sfi se.fi #define sse se.se #define fse fi.se #define lt(i, c, d) for(int i = c; i <= d; ++i) #define fl(i, c, d) for(int i = d; i >= c; --i) #define pb push_back #define emb emplace_back #define em emplace using namespace std; const int N=1e6+5,lg=20,mod=998244353; mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); int Rand(int u,int v){ return u+rd()%(v-u+1); } int n,m; vector<ii>a[N]; bool k[N],k1[N]; vector<int> eul(int u){ vector<int> ans={u}; while(!a[u].empty()){ k1[u]=true; int v=a[u].back().fi; int i=a[u].back().se; a[u].pop_back(); if(k[i])continue; k[i]=true; u=v; ans.emb(u); } for(auto it=++ans.begin();it!=ans.end();++it){ vector<int>t=eul(*it); t.pop_back(); ans.insert(it,t.begin(),t.end()); } return ans; } bool h[N]; void solve(){ cin >> n >> m; for(int i=1;i<=m;++i){ int u,v; cin >> u >> v; a[u].emb(v,i); a[v].emb(u,i); } for(int i=1;i<=n;++i) if(!k1[i]){ vector<int>res=eul(i); stack<int>s; for(int i:res){ if(h[i]){ while(!s.empty()&&h[i]){ h[s.top()]=false; cout <<s.top()<<" "; s.pop(); } cout<<'\n'; } h[i]=true; s.push(i); } } // cout <<1; } main() { srand(time(0)); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } int t=1; // cin >> t; while(t--){ solve(); // cout<<'\n'; } }

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

postmen.cpp:77:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   77 | main()
      | ^~~~
postmen.cpp: In function 'int main()':
postmen.cpp:84:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |       freopen(task".inp","r",stdin);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
postmen.cpp:85:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |       freopen(task".out","w",stdout);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...