Submission #292213

#TimeUsernameProblemLanguageResultExecution timeMemory
292213davooddkareshkiSenior Postmen (BOI14_postmen)C++17
55 / 100
539 ms58824 KiB
#include<bits/stdc++.h> using namespace std; //#define int long long #define F first #define S second #define pii pair<int,int> #define mpr make_pair #pragma GCC optimize("O1") #pragma GCC optimize("O2") #pragma GCC optimize("O3") #pragma GCC optimize("O4") #pragma GCC optimize("O5") #pragma GCC optimize("O6") #pragma GCC optimize("O7") #pragma GCC optimize("O8") #pragma GCC optimize("O9") #pragma GCC optimize("Ofast") typedef long long ll; const int maxn = 5e5; const int mod = 1e9+7; int n, m, k; bitset<maxn> mark_E; vector<pii> g[maxn]; int ptr[maxn]; bitset<maxn> mark; vector<int> stk; void DO(int v) { if(mark[v]) { while(stk.back() != v) { int u = stk.back(); mark[u] = 0; printf("%d ", u+1); stk.pop_back(); } mark[v] = 0; printf("%d\n", v+1); stk.pop_back(); } mark[v] = 1; stk.push_back(v); } void dfs(int v) { for(; ptr[v] < (int)g[v].size(); ++ptr[v]) { pii e = g[v][ptr[v]]; int u = e.F, id = e.S; if(!mark_E[id]) { mark_E[id] = 1; dfs(u); DO(u); } } } signed main() { //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); scanf("%d%d", &n, &m); for(int i = 0, u, v; i < m; ++i) { scanf("%d%d", &u, &v); --u; --v; g[u].push_back({v,i}); g[v].push_back({u,i}); } dfs(0); DO(0); } /* 10 15 1 3 5 1 2 3 9 2 3 4 6 3 4 5 7 4 4 8 5 7 8 5 6 7 7 8 8 10 10 9 */

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:72:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   72 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:75:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   75 |         scanf("%d%d", &u, &v); --u; --v;
      |         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...