Submission #1118304

#TimeUsernameProblemLanguageResultExecution timeMemory
1118304asli_bgSenior Postmen (BOI14_postmen)C++11
0 / 100
5 ms6748 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define all(x) x.begin(),x.end() #define sp <<' '<< #define pb push_back #define FOR(i,a) for(int i=0;i<(a);i++) #define FORE(i,a,b) for(int i=(a);i<(b);i++) #define cont(a) for(auto el:a) cout<<el<<' '; cout<<endl; #define contp(a) for(auto el:a) cout<<el.fi<<'-'<<el.se<<' ';cout<<endl; #define DEBUG(x) cout<<#x sp ":" sp x<<endl; typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pii> vii; typedef long long ll; #define endl '\n' #define mid (l+r)/2 #define topla(x,y) ((x%MOD)+(y%MOD))%MOD #define carp(x,y) ((x%MOD)*(y%+MOD))%MOD const int MAXN=2e5+5; const int INF=1e16; int n,m; vii adj[MAXN]; int vis[MAXN]; vi cev; void dfs(int nd){ while(!adj[nd].empty()){ auto el=adj[nd].back(); int kom=el.fi; int yol=el.se; adj[nd].pop_back(); if(vis[yol]) continue; vis[yol]=true; dfs(kom); } cev.pb(nd); } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>m; FOR(i,m){ int a,b; cin>>a>>b; adj[a].pb({b,i+1}); adj[b].pb({a,i+1}); } //find eulerian circuit dfs(1); vi st; FORE(i,1,n+1) vis[i]=false; vector<vi> ans; vi temp; int cur=1; FOR(i,cev.size()){ int kom=cev[i]; int f=0; if(vis[kom]==cur){ int el; do{ el=st.back(); st.pop_back(); temp.pb(el); }while(el!=kom); ans.pb(temp); temp.clear(); f=1; } st.pb(kom); vis[kom]=cur; cur+=f; } st.pop_back(); if(!st.empty()) ans.pb(st); for(auto el:ans){ cont(el); } }

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:12:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 | #define FOR(i,a) for(int i=0;i<(a);i++)
      |                               ^
postmen.cpp:80:5: note: in expansion of macro 'FOR'
   80 |     FOR(i,cev.size()){
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...