Submission #1067600

#TimeUsernameProblemLanguageResultExecution timeMemory
1067600MilosMilutinovicMake them Meet (EGOI24_makethemmeet)C++14
10 / 100
1 ms348 KiB
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  if (m == n - 1 && (int) g[0].size() == n - 1) {
    // Subtask 1
    cout << 2 * (n - 1) + 1 << '\n';
    for (int i = 0; i < n; i++) {
      cout << 1 << " ";
    }
    cout << '\n';
    for (int i = 1; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (j == 0 || j == i) {
          cout << 1 << " ";
        } else {
          cout << 2 << " ";
        }
      }
      cout << '\n';
      for (int j = 0; j < n; j++) {
        if (j == 0 || j == i) {
          cout << 1 << " ";
        } else {
          cout << 2 << " ";
        }
      }
      cout << '\n';
    }
  }
  return 0;
}
#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...