Submission #1119656

#TimeUsernameProblemLanguageResultExecution timeMemory
1119656vjudge1Senior Postmen (BOI14_postmen)C++17
0 / 100
23 ms24400 KiB
#include<bits/stdc++.h> using namespace std; #define task "comseq" #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,vis[maxn]; vector<int>ans; vector<ii>a[maxn]; void dfs(int u) { ans.push_back(u); while(!a[u].empty()) { int tmp=a[u].back().fi; int vt=a[u].back().se; a[u].pop_back(); if(!vis[vt]){ vis[vt]=1; dfs(tmp); } } } 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}); } dfs(1); reverse(ans.begin(),ans.end()); stack<int>s; for(int i=0;i<ans.size();i++) { if(pos[ans[i]]==0)pos[ans[i]]=1; else { while(true) { int t=s.top();s.pop(); pos[t]=0; cout<<t<<" "; if(t==ans[i])break; } cout<<'\n'; } pos[ans[i]]=1; s.push(ans[i]); } cerr <<endl<< "TIME : " << clock() * 0.001 << "s" << endl ; }

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:58:18: 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]
   58 |     for(int i=0;i<ans.size();i++)
      |                 ~^~~~~~~~~~~
postmen.cpp:45:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
postmen.cpp:46:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |     freopen(task".out","w",stdout);}
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...