Submission #841364

# Submission time Handle Problem Language Result Execution time Memory
841364 2023-09-01T14:59:35 Z hcng Soccer Stadium (IOI23_soccer) C++17
1.5 / 100
232 ms 31764 KB
#include <bits/stdc++.h>
#include "soccer.h"

using namespace std;

int biggest_stadium(int n, vector<vector<int>> f) {
    int cnt = 0;
    vector<pair<int, int>> v;
    bool flag = false;
    for (int i = 0; i < n; i++) {
        int l = -1, r = -1;
        for (int j = 0; j < n; j++) {
            if (f[i][j] == 0) cnt++;
            if (f[i][j] == 0 && l == -1) {
                l = j;
            }
            if (f[i][j] == 0 && r != -1) {
                return -1;
            }
            if (f[i][j] == 1 && l != -1) {
                r = j - 1;
            }
        }
        if (l != -1 && r == -1) r = n - 1;
        if (!v.empty() && l == -1) {
            flag = true;
        }
        if (flag && l != -1) {
            return -1;
        }
        if (l != -1) v.emplace_back(l, r);
    }
    for (int i = 0; i < v.size(); i++) {
        for (int j = i + 1; j < v.size(); j++) {
            if ((v[i].first > v[j].first && v[i].second > v[j].second) || (v[i].first < v[j].first && v[i].second < v[j].second)) {
                return -1;
            }
        }
    }
    flag = false;
    for (int i = 1; i < v.size(); i++) {
        if (!flag) {
            if (!(v[i].first <= v[i - 1].first && v[i].second >= v[i - 1].first)) {
                flag = true;
            }
        } else {
            if (!(v[i].first >= v[i - 1].first && v[i].second <= v[i - 1].first)) {
                return -1;
            }
        }
    }
    return cnt;
}

Compilation message

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for (int i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
soccer.cpp:34:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for (int j = i + 1; j < v.size(); j++) {
      |                             ~~^~~~~~~~~~
soccer.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int i = 1; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 212 KB partial
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB ok
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 0 ms 212 KB ok
5 Correct 0 ms 212 KB ok
6 Partially correct 0 ms 212 KB partial
7 Partially correct 2 ms 340 KB partial
8 Partially correct 19 ms 2260 KB partial
9 Partially correct 232 ms 31764 KB partial
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB ok
2 Correct 0 ms 212 KB ok
3 Partially correct 1 ms 212 KB partial
4 Incorrect 0 ms 212 KB wrong
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 212 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Partially correct 1 ms 212 KB partial
5 Incorrect 0 ms 212 KB wrong
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 212 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 0 ms 212 KB ok
5 Correct 0 ms 212 KB ok
6 Partially correct 1 ms 212 KB partial
7 Incorrect 0 ms 212 KB wrong
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 212 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 0 ms 212 KB ok
5 Correct 0 ms 212 KB ok
6 Partially correct 1 ms 212 KB partial
7 Incorrect 0 ms 212 KB wrong
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 212 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 0 ms 212 KB ok
5 Correct 0 ms 212 KB ok
6 Correct 0 ms 212 KB ok
7 Partially correct 0 ms 212 KB partial
8 Partially correct 2 ms 340 KB partial
9 Partially correct 19 ms 2260 KB partial
10 Partially correct 232 ms 31764 KB partial
11 Partially correct 1 ms 212 KB partial
12 Incorrect 0 ms 212 KB wrong
13 Halted 0 ms 0 KB -