답안 #900219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
900219 2024-01-07T22:33:58 Z MilosMilutinovic 축구 경기장 (IOI23_soccer) C++17
1.5 / 100
639 ms 369220 KB
#include "soccer.h"
#include <bits/stdc++.h>

using namespace std;

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

bool check_all(int n, vector<vector<int>> a) {
  vector<vector<bool>> was(n, vector<bool>(n));
  function<void(int, int)> Dfs = [&](int x, int y) {
    if (x < 0 || x >= n || y < 0 || y >= n || a[x][y] == 1 || was[x][y]) {
      return;
    }
    was[x][y] = true;
    for (int d = 0; d < 4; d++) {
      Dfs(x + dx[d], y + dy[d]);
    }
  };
  bool done = false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!done && a[i][j] == 0) {
        Dfs(i, j);
        done = true;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i][j] == 0 && !was[i][j]) {
        return false;
      }
    }
  }
  vector<pair<int, int>> seg;
  for (int j = 0; j < n; j++) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (a[i][j] == 1) {
        continue;
      }
      cnt += 1;
      if (cnt == 2) {
        return false;
      }
      int ptr = i;
      while (ptr + 1 < n && a[ptr + 1][j] == 0) {
        ptr += 1;
      }
      seg.emplace_back(i, ptr);
      i = ptr;
    }
  }
  int sz = (int) seg.size();
  int ptr = 0;
  while (ptr + 1 < sz && seg[ptr + 1].first <= seg[ptr].first && seg[ptr].second <= seg[ptr + 1].second) {
    ptr += 1;
  }
  while (ptr + 1 < sz && seg[ptr].first <= seg[ptr + 1].first && seg[ptr + 1].second <= seg[ptr].second) {
    ptr += 1;
  }
  return ptr == sz - 1;
}

int biggest_stadium(int n, vector<vector<int>> a) {
  if (check_all(n, a)) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (a[i][j] == 0) {
          cnt += 1;
        }
      }
    }
    return cnt;
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 1 ms 344 KB ok
3 Correct 1 ms 600 KB ok
4 Correct 1 ms 756 KB ok
5 Correct 1 ms 344 KB ok
6 Partially correct 0 ms 348 KB partial
7 Partially correct 2 ms 1116 KB partial
8 Partially correct 36 ms 23380 KB partial
9 Partially correct 639 ms 369220 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 1 ms 344 KB ok
3 Partially correct 1 ms 344 KB partial
4 Partially correct 0 ms 348 KB partial
5 Partially correct 0 ms 544 KB partial
6 Incorrect 0 ms 348 KB wrong
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
2 Correct 0 ms 344 KB ok
3 Correct 1 ms 344 KB ok
4 Partially correct 1 ms 344 KB partial
5 Partially correct 0 ms 348 KB partial
6 Partially correct 0 ms 544 KB partial
7 Incorrect 0 ms 348 KB wrong
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
2 Correct 0 ms 344 KB ok
3 Correct 1 ms 344 KB ok
4 Correct 1 ms 600 KB ok
5 Correct 1 ms 756 KB ok
6 Partially correct 1 ms 344 KB partial
7 Partially correct 0 ms 348 KB partial
8 Partially correct 0 ms 544 KB partial
9 Incorrect 0 ms 348 KB wrong
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
2 Correct 0 ms 344 KB ok
3 Correct 1 ms 344 KB ok
4 Correct 1 ms 600 KB ok
5 Correct 1 ms 756 KB ok
6 Partially correct 1 ms 344 KB partial
7 Partially correct 0 ms 348 KB partial
8 Partially correct 0 ms 544 KB partial
9 Incorrect 0 ms 348 KB wrong
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
2 Correct 0 ms 344 KB ok
3 Correct 1 ms 344 KB ok
4 Correct 1 ms 600 KB ok
5 Correct 1 ms 756 KB ok
6 Correct 1 ms 344 KB ok
7 Partially correct 0 ms 348 KB partial
8 Partially correct 2 ms 1116 KB partial
9 Partially correct 36 ms 23380 KB partial
10 Partially correct 639 ms 369220 KB partial
11 Partially correct 1 ms 344 KB partial
12 Partially correct 0 ms 348 KB partial
13 Partially correct 0 ms 544 KB partial
14 Incorrect 0 ms 348 KB wrong
15 Halted 0 ms 0 KB -