Submission #356249

#TimeUsernameProblemLanguageResultExecution timeMemory
356249parsabahramiSenior Postmen (BOI14_postmen)C++17
55 / 100
786 ms93676 KiB
// Call my Name and Save me from The Dark #include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") using namespace std; typedef long long int ll; typedef pair<int, int> pii; #define SZ(x) (int) x.size() #define F first #define S second const int N = 5e5 + 10; int M[N], ptr[N], from[N], to[N], n, m; vector<int> adj[N]; set<pii> tr; void tour(int v) { while (ptr[v] < SZ(adj[v])) { int id = adj[v][ptr[v]++]; int u = from[id] ^ v ^ to[id]; if (!M[id]) M[id] = 1, tour(u); } tr.insert({SZ(tr) + 1, v}); } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { scanf("%d%d", &from[i], &to[i]); adj[from[i]].push_back(i); adj[to[i]].push_back(i); } for (int i = 1; i <= n; i++) assert(!(SZ(adj[i]) & 1)); tour(1); memset(M, 0, sizeof M); for (auto it = tr.begin(); it != tr.end(); it = tr.upper_bound(*it)) { if (M[it->S]) { for (auto it2 = tr.lower_bound({M[it->S], it->S}); it2 != it;) { M[it2->S] = 0; printf("%d ", it2->S); it2 = tr.erase(it2); } printf("\n"); M[it->S] = it->F; } else M[it->S] = it->F; } return 0; }

Compilation message (stderr)

postmen.cpp:3: warning: ignoring #pragma comment  [-Wunknown-pragmas]
    3 | #pragma comment(linker, "/stack:200000000")
      | 
postmen.cpp: In function 'int main()':
postmen.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |         scanf("%d%d", &from[i], &to[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...