답안 #1067617

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067617 2024-08-20T21:36:34 Z MilosMilutinovic Make them Meet (EGOI24_makethemmeet) C++14
14.0802 / 100
52 ms 3152 KB
#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);
  }
  auto Subtask1 = [&]() {
    return m == n - 1 && (int) g[0].size() == n - 1;
  };
  auto Subtask2 = [&]() {
    return m == n * (n - 1) / 2;
  };
  auto Subtask3 = [&]() {
    bool ok = (m == n - 1);
    for (int i = 0; i < n; i++) {
      for (int j : g[i]) {
        if (abs(i - j) > 1) {
          ok = false;
        }
      }
    }
    return ok;
  };
  if (Subtask1()) {
    // 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;
  }
  if (Subtask3()) {
    cout << (n - 1) * (n - 1) << '\n';
    for (int i = 0; i + 1 < n; i++) {
      for (int j = 0; j + 1 < n; j++) {
        int col = 2;
        for (int k = 0; k < n; k++) {
          if (k == j || k == j + 1) {
            cout << 1 << " ";
          } else {
            cout << col << " ";
            col += 1;
          }
        }
        cout << '\n';
      }
    }
    return 0;
  }
  return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:20:8: warning: variable 'Subtask2' set but not used [-Wunused-but-set-variable]
   20 |   auto Subtask2 = [&]() {
      |        ^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Partially correct 6 ms 636 KB Partially correct
5 Partially correct 52 ms 3068 KB Partially correct
6 Partially correct 43 ms 3144 KB Partially correct
7 Partially correct 18 ms 1116 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Partially correct 6 ms 636 KB Partially correct
10 Partially correct 52 ms 3068 KB Partially correct
11 Partially correct 43 ms 3144 KB Partially correct
12 Partially correct 18 ms 1116 KB Partially correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 2 ms 508 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 356 KB Output is correct
20 Partially correct 7 ms 604 KB Partially correct
21 Partially correct 40 ms 2988 KB Partially correct
22 Partially correct 41 ms 3152 KB Partially correct
23 Partially correct 11 ms 1116 KB Partially correct
24 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
8 Halted 0 ms 0 KB -