답안 #1059738

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1059738 2024-08-15T07:40:31 Z dozer 축구 경기장 (IOI23_soccer) C++17
1.5 / 100
187 ms 39696 KB
#include "soccer.h"
#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;

int dp[2][MAXN][MAXN][MAXN][MAXN], prv[2][MAXN][MAXN][MAXN][MAXN];


int biggest_stadium(int N, vector<std::vector<int>> F)
{   
    int n = N;
    vector<vector<pii>> ranges(n);;
    int sum = 0;
    for (int i = 0; i < n; i++){
        int it = 0;
        while(it < n){
            if (F[i][it] == 1) {
                it++;
                continue;
            }
            int lst = it;
            while(it < n && F[i][it] == 0) it++;
            ranges[i].pb({lst, it - 1});
            sum += it - lst;
        }
    }

    int start = 0;
    while(start < n && ranges[start].empty()) start++;
    if (start == n) return 0;
    int end = start;
    int curr_sum = 0;
    while(end < n && !ranges[end].empty()) {
        curr_sum += ranges[end][0].nd - ranges[end][0].st + 1;
        end++;
    }

    for (int i = 0; i < n; i++){
        if (ranges[i].size() > 1) return 0;
    }

    if (curr_sum != sum) return 0;

    vector<pii> r;
    for (int i = start; i < end; i++) r.pb(ranges[i][0]);

    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;
        }
    }
    return sum;
}
/*
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 biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:71: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]
   71 |     for (int i = 1; i < r.size(); i++){
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 444 KB ok
4 Correct 1 ms 344 KB ok
5 Correct 0 ms 344 KB ok
6 Partially correct 1 ms 344 KB partial
7 Partially correct 1 ms 348 KB partial
8 Partially correct 26 ms 2708 KB partial
9 Partially correct 187 ms 39696 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB ok
2 Correct 0 ms 348 KB ok
3 Partially correct 0 ms 344 KB partial
4 Incorrect 0 ms 348 KB wrong
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
2 Correct 1 ms 344 KB ok
3 Correct 0 ms 348 KB ok
4 Partially correct 0 ms 344 KB partial
5 Incorrect 0 ms 348 KB wrong
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
2 Correct 1 ms 344 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 444 KB ok
5 Correct 1 ms 344 KB ok
6 Partially correct 0 ms 344 KB partial
7 Incorrect 0 ms 348 KB wrong
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
2 Correct 1 ms 344 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 444 KB ok
5 Correct 1 ms 344 KB ok
6 Partially correct 0 ms 344 KB partial
7 Incorrect 0 ms 348 KB wrong
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
2 Correct 1 ms 344 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 444 KB ok
5 Correct 1 ms 344 KB ok
6 Correct 0 ms 344 KB ok
7 Partially correct 1 ms 344 KB partial
8 Partially correct 1 ms 348 KB partial
9 Partially correct 26 ms 2708 KB partial
10 Partially correct 187 ms 39696 KB partial
11 Partially correct 0 ms 344 KB partial
12 Incorrect 0 ms 348 KB wrong
13 Halted 0 ms 0 KB -