Submission #1195826

#TimeUsernameProblemLanguageResultExecution timeMemory
1195826badge881Make them Meet (EGOI24_makethemmeet)C++20
70 / 100
5 ms584 KiB
#include <bits/stdc++.h> using namespace std; long long N, M; vector<vector<int>> graph; vector<vector<int>> matrix; vector<int> p1, p2; vector<int> vis; void dfs(int n, int parity) { vis[n] = true; for (auto go : graph[n]) { if (vis[go]) continue; if (parity) { p2[go] = p2[n]; } else { p1[go] = p1[n]; } dfs(go, 1 - parity); } } int main() { scanf("%lld%lld", &N, &M); graph.resize(N), matrix.resize(N, vector<int>(N)), p1.resize(N), p2.resize(N), vis.resize(N, false); for (int i = 0; i < M; i++) { int a, b; scanf("%d%d", &a, &b); matrix[a][b] = 1; matrix[b][a] = 1; graph[a].push_back(b); graph[b].push_back(a); } for (int i = 0; i < N; i++) { p1[i] = i + 1; p2[i] = i + 1; matrix[i][i] = 1; } int root = -1; for (int i = 0; i < N; i++) { for (auto j : graph[i]) { for (auto u : graph[j]) if (matrix[i][u] == 0) { p2[j] = p2[u] = p2[i]; vis[u] = true; dfs(i, 0); dfs(u, 0); root = j; break; } if (root != -1) break; } if (root != -1) break; } if (root == -1) dfs(0, 0); printf("600\n"); for (int i = 0; i < 300; i++) { for (int k = 0; k < N; k++) printf("%d ", p2[k]); printf("\n"); for (int k = 0; k < N; k++) printf("%d ", p1[k]); printf("\n"); } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     scanf("%lld%lld", &N, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         scanf("%d%d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...