답안 #1059796

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1059796 2024-08-15T08:14:33 Z dozer 축구 경기장 (IOI23_soccer) C++17
13.5 / 100
4500 ms 583764 KB
#include "soccer.h"
//brute fooorceee
#include <bits/stdc++.h>
using namespace std;
#define sp " " 
#define endl "\n"
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define LL node * 2
#define RR node * 2 + 1
#define ll long long
#define MAXN 35

const int modulo = 1e9 + 7;
const ll INF = 2e18 + 7;

map<vector<pii>, int> m;


int check(vector<pii> &r){
    if (r.empty()) return 1;

    for (auto i : r){
        for (auto j : r){
            int l = j.st, r = j.nd;
            if (l < i.st && r < i.nd) return 0;
            if (l > i.st && r > i.nd) return 0;
        }
    }
    int dec = 0;
    pii last = r.front();
    for (int i = 1; i < r.size(); i++){
        if (r[i].st > last.st || r[i].nd < last.nd){
            dec = 1;
        }
        else if (r[i].st < last.st || r[i].nd > last.nd){
            if (dec == 1) return 0;
        }
        last = r[i];
    }
    return 1;
}


int f(vector<pii> &curr, vector<vector<int>> &pre, int ind){
    if (check(curr) == 0) return -modulo;
    if (!curr.empty() && m.count(curr)) return m[curr];
    int n = pre.size();
    if (ind == n){
        return m[curr] = 0;
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i; j < n; j++){
            int sum = pre[ind][j];
            if (i > 0) sum -= pre[ind][i - 1];
            if (sum != 0) continue;
            curr.pb({i, j});
            ans = max(ans, f(curr, pre, ind + 1) + j - i + 1);
            curr.pop_back();
        }
    }

    if (curr.empty()) ans = max(ans, f(curr, pre, ind + 1));
    return m[curr] = ans;
}



int biggest_stadium(int N, vector<std::vector<int>> F)
{   
    int n = N;
    vector<vector<int>> pre = F;
    for (int i = 0; i < n; i++)
        for (int j = 1; j < n; j++) pre[i][j] += pre[i][j - 1];

    vector<pii> tmp;
    return f(tmp, pre, 0);
}
/*
int main()
{
    fileio();
    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;
}*/

Compilation message

soccer.cpp: In function 'int check(std::vector<std::pair<int, int> >&)':
soccer.cpp:36: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]
   36 |     for (int i = 1; i < r.size(); i++){
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Execution timed out 4595 ms 583764 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 1 ms 348 KB ok
9 Correct 1 ms 348 KB ok
10 Correct 0 ms 348 KB ok
11 Correct 0 ms 344 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 0 ms 348 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 1 ms 348 KB ok
10 Correct 1 ms 348 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 0 ms 344 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 0 ms 348 KB ok
15 Correct 545 ms 81748 KB ok
16 Correct 97 ms 12736 KB ok
17 Correct 2 ms 696 KB ok
18 Correct 0 ms 348 KB ok
19 Partially correct 0 ms 348 KB partial
20 Correct 0 ms 348 KB ok
21 Correct 0 ms 348 KB ok
22 Correct 0 ms 348 KB ok
23 Correct 1 ms 348 KB ok
24 Correct 1 ms 348 KB ok
25 Correct 2 ms 604 KB ok
26 Correct 12 ms 2348 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Execution timed out 4595 ms 583764 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Execution timed out 4595 ms 583764 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Execution timed out 4595 ms 583764 KB Time limit exceeded
5 Halted 0 ms 0 KB -