답안 #963947

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963947 2024-04-16T05:04:59 Z nguyentunglam 축구 경기장 (IOI23_soccer) C++17
0 / 100
1 ms 604 KB
#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;

const int N = 2010;

int n;

bool a[N][N];

vector<int> arr[N];

int check_valid() {
  for(int col = 0; col < n; col++) {
    for(int row = 0; row < n; row++) if (a[row][col] == 0) arr[col].push_back(row);
  }

  int st = 0;
  while (st < n && arr[st].empty()) st++;
  if (st == n) return 0;
  int ed = st;

  while (ed < n && !arr[ed].empty()) ed++; ed--;
  for(int i = 1; i < st; i++) if (!arr[i].empty()) return 0;
  for(int i = ed + 1; i < n; i++) if (!arr[i].empty()) return 0;

  int cnt = 0;

  for(int i = st; i <= ed; i++) cnt += arr[i].size();

  int L = max(arr[st][0], arr[ed][0]);
  int R = min(arr[st].back(), arr[ed].back());
  while (st <= ed) {
    if (arr[st].size() <= arr[ed].size()) {
      if (arr[st][0] <= L && arr[st].back() >= R) {
        L = arr[st][0];
        R = arr[st].back();
        st++;
      }
      else return 0;
    }
    else {
      if (arr[ed][0] <= L && arr[ed].back() >= R) {
        L = arr[ed][0];
        R = arr[ed].back();
        ed--;
      }
      else return 0;
    }
  }
  return cnt;
}

int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
  n = N;
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) a[i][j] = F[i][j];
  return check_valid();
}

#ifdef ngu
int main()
{
  freopen ("task.inp", "r", stdin);
  freopen ("task.out", "w", stdout);
    int N;
    assert(1 == scanf("%d", &N));
    std::vector<std::vector<int>> F(N, std::vector<int>(N));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            assert(1 == scanf("%d", &F[i][j]));
        }
    }
    fclose(stdin);

    int res = biggest_stadium(N, F);

    printf("%d\n", res);
    fclose(stdout);
    return 0;
}
#endif // ngu

Compilation message

soccer.cpp: In function 'int check_valid()':
soccer.cpp:23:3: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   23 |   while (ed < n && !arr[ed].empty()) ed++; ed--;
      |   ^~~~~
soccer.cpp:23:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   23 |   while (ed < n && !arr[ed].empty()) ed++; ed--;
      |                                            ^~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 348 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 0 ms 352 KB ok
4 Correct 1 ms 604 KB ok
5 Correct 0 ms 492 KB ok
6 Incorrect 1 ms 344 KB wrong
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 1 ms 348 KB ok
3 Partially correct 1 ms 348 KB partial
4 Incorrect 1 ms 348 KB wrong
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 348 KB partial
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Partially correct 1 ms 348 KB partial
5 Incorrect 1 ms 348 KB wrong
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 348 KB partial
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 0 ms 352 KB ok
5 Correct 1 ms 604 KB ok
6 Partially correct 1 ms 348 KB partial
7 Incorrect 1 ms 348 KB wrong
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 348 KB partial
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 0 ms 352 KB ok
5 Correct 1 ms 604 KB ok
6 Partially correct 1 ms 348 KB partial
7 Incorrect 1 ms 348 KB wrong
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 348 KB partial
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 0 ms 352 KB ok
5 Correct 1 ms 604 KB ok
6 Correct 0 ms 492 KB ok
7 Incorrect 1 ms 344 KB wrong
8 Halted 0 ms 0 KB -