Submission #861182

# Submission time Handle Problem Language Result Execution time Memory
861182 2023-10-15T15:13:18 Z GordonRemzi007 Soccer Stadium (IOI23_soccer) C++17
0 / 100
4500 ms 348 KB
#include <iostream>
#include <vector>

using namespace std;

int biggest_stadium(int n, vector<vector<int>> a) {
    int res = 1, temp, down, up;
    bool ok, can1, can2;
    vector<pair<int,int>> free;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(!a[i][j]) free.push_back({i, j});
        }
    }
    for(int i = 2; i < (1<<free.size()); i++) {
        temp = i;
        vector<int> tempfree;
        for(int i = 0; i < free.size() && temp > 0; i++, temp/=2) {
            if(temp%2==0) tempfree.push_back(i);
        }
        ok = true;
        for(int i = 0; i < tempfree.size(); i++) {
            for(int j = 0; j < tempfree.size(); j++) {
                if(free[tempfree[i]].first < free[tempfree[j]].first) {
                    down = tempfree[i];
                    up = tempfree[j];
                } else {
                    down = tempfree[j];
                    up = tempfree[i];
                }
                can1 = true, can2 = true;
                //most down - upwards - then to the other
                for(int z = free[down].first; z <= free[up].first; z++) {
                    if(a[z][free[down].second]) can1 = false;
                }
                for(int z = min(free[down].second, free[up].second); z <= max(free[down].second, free[up].second); z++) {
                    if(a[free[up].first][z]) can1 = false;
                }
                //most up - downwards - then to the other
                for(int z = free[down].first; z <= free[up].first; z++) {
                    if(a[z][free[up].second]) can2 = false;
                }
                for(int z = min(free[down].second, free[up].second); z <= max(free[down].second, free[up].second); z++) {
                    if(a[free[down].first][z]) can2 = false;
                }

                if(!can1 && !can2) ok = false;
            }
        }
        if(ok) res = max(res, (int)tempfree.size());
    }
    return res;
}

Compilation message

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:18:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         for(int i = 0; i < free.size() && temp > 0; i++, temp/=2) {
      |                        ~~^~~~~~~~~~~~~
soccer.cpp:22:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int i = 0; i < tempfree.size(); i++) {
      |                        ~~^~~~~~~~~~~~~~~~~
soccer.cpp:23:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |             for(int j = 0; j < tempfree.size(); j++) {
      |                            ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 4531 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4531 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4531 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4531 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4531 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -