Submission #1195389

#TimeUsernameProblemLanguageResultExecution timeMemory
1195389mannshah1211Soccer Stadium (IOI23_soccer)C++20
Compilation error
0 ms0 KiB
#include "soccer.h"
#include <bits/stdc++.h>

using namespace std;

int biggest_stadium(int n, vector<vector<int>> f) {
  vector<pair<int, int>> ranges_r, ranges_c;
  for (int i = 0; i < n; i++) {
    int mx = 0, mn = n, cnt = 0;
    for (int j = 0; j < n; j++) {
      if (f[i][j] == 0) {
        mx = max(mx, j);
        mn = min(mn, j);
        cnt++;
      }
    }
    if (mx - mn + 1 != cnt && cnt != 0) {
      return 0;
    }
    ranges_r.emplace_back(mn, mx);
  }
  sort(ranges_r.begin(), ranges_r.end(), [&](pair<int, int> x, pair<int, int> y) {
    return (x.second - x.first < y.second - y.first);
  });
  for (int i = 0; i < int(ranges_r.size()) - 1; i++) {
    auto [a, b] = ranges_r[i], [c, d] = ranges_r[i];
    if (a >= c && b <= d) {
      continue;
    }
    if (c >= a && d <= b) {
      continue;
    }
    return 0;
  }
  for (int j = 0; j < n; j++) {
    int mx = 0, mn = n, cnt = 0;
    for (int i = 0; i < n; i++) {
      if (f[i][j] == 0) {
        mx = max(mx, i);
        mn = min(mn, i);
        cnt++;
      }
    }
    if (mx - mn + 1 != cnt && cnt != 0) {
      return 0;
    }
    ranges_c.emplace_back(mn, mx);
  }
  sort(ranges_c.begin(), ranges_c.end(), [&](pair<int, int> x, pair<int, int> y) {
    return (x.second - x.first < y.second - y.first);
  });
  for (int i = 0; i < int(ranges_c.size()) - 1; i++) {
    auto [a, b] = ranges_c[i], [c, d] = ranges_c[i];
    if (a >= c && b <= d) {
      continue;
    }
    if (c >= a && d <= b) {
      continue;
    }
    return 0;
  }
  int tot = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      tot += (f[i][j] == 0);
    }
  }
  return tot;
}

Compilation message (stderr)

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:26:30: error: expected ';' before ',' token
   26 |     auto [a, b] = ranges_r[i], [c, d] = ranges_r[i];
      |                              ^
soccer.cpp:27:14: error: 'c' was not declared in this scope
   27 |     if (a >= c && b <= d) {
      |              ^
soccer.cpp:27:24: error: 'd' was not declared in this scope
   27 |     if (a >= c && b <= d) {
      |                        ^
soccer.cpp:30:9: error: 'c' was not declared in this scope
   30 |     if (c >= a && d <= b) {
      |         ^
soccer.cpp:30:19: error: 'd' was not declared in this scope
   30 |     if (c >= a && d <= b) {
      |                   ^
soccer.cpp:53:30: error: expected ';' before ',' token
   53 |     auto [a, b] = ranges_c[i], [c, d] = ranges_c[i];
      |                              ^
soccer.cpp:54:14: error: 'c' was not declared in this scope
   54 |     if (a >= c && b <= d) {
      |              ^
soccer.cpp:54:24: error: 'd' was not declared in this scope
   54 |     if (a >= c && b <= d) {
      |                        ^
soccer.cpp:57:9: error: 'c' was not declared in this scope
   57 |     if (c >= a && d <= b) {
      |         ^
soccer.cpp:57:19: error: 'd' was not declared in this scope
   57 |     if (c >= a && d <= b) {
      |                   ^