Submission #1118307

#TimeUsernameProblemLanguageResultExecution timeMemory
1118307asli_bgSenior Postmen (BOI14_postmen)C++11
55 / 100
66 ms20956 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]; bool 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; FOR(i,cev.size()){ int kom=cev[i]; if(vis[kom]){ int el; do{ el=st.back(); st.pop_back(); temp.pb(el); vis[el]=false; }while(el!=kom); ans.pb(temp); temp.clear(); } st.pb(kom); vis[kom]=true; } 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:79:5: note: in expansion of macro 'FOR'
   79 |     FOR(i,cev.size()){
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...