#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ii = pair<int, int>;
vector<ii> Sol;
int sum(int lin, int l, int r, vector<vi> &SL) {
if(!l) return SL[lin][r];
return SL[lin][r] - SL[lin][l - 1];
}
bool ok(int l1, int r1, int l2, int r2) {
if(l1 > l2) {
swap(l1, l2);
swap(r1, r2);
}
if(r2 <= r1) return 1;
return l2 == l1;
}
int reg, nrsol;
void gen(int n, int lin, vector<vi> &SL, int rec) {
reg = max(reg, rec);
// if(rec == 21) {
// for(auto [a, b] : Sol)
// cout << a << " " << b << "\n";
// cout << "\n\n";
// }
++nrsol;
if(lin == n)
return;
for(int i = 0; i < n; ++i) {
for(int j = i; j < n; ++j) {
if(!sum(lin, i, j, SL)) {
bool cont = 1;
if(!Sol.empty()) {
auto [st, dr] = Sol.back();
for(int i = Sol.size() - 1; i >= 0; --i) {
if(Sol[i].first < st && i < st) {
cont = 0;
break;
}
if(Sol[i].second > dr && j > dr) {
cont = 0;
break;
}
st = max(st, Sol[i].first);
dr = min(dr, Sol[i].second);
}
if(!cont) continue;
}
for(auto it : Sol)
cont &= ok(it.first, it.second, i, j);
if(cont) {
Sol.push_back({i, j});
gen(n, lin + 1, SL, rec + j - i + 1);
Sol.pop_back();
}
}
}
}
}
int biggest_stadium(int n, std::vector<std::vector<int>> F) {
vector<vi> SL(n, vi(n, 0));
int nrtree = 0;
for(int i = 0; i < n; ++i) {
SL[i][0] = F[i][0];
for(auto it : F[i])
nrtree += it;
for(int j = 1; j < n; ++j)
SL[i][j] = SL[i][j - 1] + F[i][j];
}
if(!nrtree) return n * n;
reg = 0;
gen(n, 0, SL, 0);
//cout << nrsol << " - \n";
return reg;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Execution timed out |
4561 ms |
348 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
432 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
436 KB |
ok |
7 |
Correct |
1 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
436 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Partially correct |
0 ms |
348 KB |
partial |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
432 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
436 KB |
ok |
8 |
Correct |
1 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
436 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Partially correct |
0 ms |
348 KB |
partial |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Partially correct |
45 ms |
416 KB |
partial |
16 |
Partially correct |
7 ms |
436 KB |
partial |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
0 ms |
348 KB |
ok |
19 |
Partially correct |
0 ms |
344 KB |
partial |
20 |
Incorrect |
0 ms |
348 KB |
wrong |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Execution timed out |
4561 ms |
348 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Execution timed out |
4561 ms |
348 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Execution timed out |
4561 ms |
348 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |