QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#578151#7120. SoccerZanite#8 1ms4076kbC++203.0kb2024-09-20 17:01:012024-09-20 17:01:01

Judging History

你现在查看的是最新测评结果

  • [2024-09-20 17:01:01]
  • 评测
  • 测评结果:8
  • 用时:1ms
  • 内存:4076kb
  • [2024-09-20 17:01:01]
  • 提交

answer

#include "soccer.h"

#include <bits/stdc++.h>
using namespace std;

template<typename Z> bool chmin(Z &a, Z b) { return ((a > b) ? (a = b, true) : false); }
template<typename Z> bool chmax(Z &a, Z b) { return ((a < b) ? (a = b, true) : false); }

#define debug(x) cout << #x << " = " << (x) << "\n"

bool check(int N, vector<vector<int>> F) {
    vector<int> mn_row(N), mx_row(N);
    {
        for (int r = 0; r < N; r++) {
            int mn = N, mx = -1;
            for (int c = 0; c < N; c++) {
                if (!F[r][c]) { chmin(mn, c); chmax(mx, c); }
            }
            mn_row[r] = mn, mx_row[r] = mx;

            if (mn == N) continue; // no empty cell
            for (int c = mn; c <= mx; c++) {
                if (F[r][c]) return 0;
            }
        }
        for (int c = 0; c < N; c++) {
            int mn = N, mx = -1;
            for (int r = 0; r < N; r++) {
                if (!F[r][c]) { chmin(mn, r); chmax(mx, r); }
            }

            if (mn == N) continue; // no empty cell
            for (int r = mn; r <= mx; r++) {
                if (F[r][c]) return 0;
            }
        }
    }

    const auto connected = [&](int r1, int c1, int r2, int c2) {
        return (!F[r1][c2] || !F[r2][c1]);
    };

    for (int i = 0; i < N; i++) {
        if (mn_row[i] == N) continue;
        for (int j = 0; j < N; j++) {
            if (mx_row[j] == -1) continue;
            // cout << i << " " << mn_row[i] << " " << j << " " << mx_row[j] << "\n";
            if (!connected(i, mn_row[i], j, mx_row[j])) return 0;
        }
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cnt += (F[i][j] == 0);
        }
    }
    return 1;
}

int biggest_stadium(int N, vector<vector<int>> F) {
    vector<vector<pair<int, int>>> pos = {{}};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (!F[i][j]) {
                int s = pos.size();
                for (int k = 0; k < s; k++) {
                    pos.push_back(pos[k]);
                    pos.back().push_back({i, j});
                }
            }
        }
    }

    int ans = 0;
    for (auto p : pos) if (!p.empty()) {
        // for (auto [i, j] : p) { cout << i << j << " "; } cout << "\n";

        vector field(N, vector(N, 1));
        for (auto [i, j] : p) field[i][j] = 0;
        if (check(N, field)) chmax(ans, (int)p.size());
    }
    return ans;
}

#ifdef Zanite

#include "soccer.h"
#include <cassert>
#include <cstdio>
#include <vector>

int main()
{
    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;
}

#endif

详细

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 6
Accepted
time: 0ms
memory: 3772kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
1
0

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
1

result:

ok ok

Test #2:

score: 6
Accepted
time: 0ms
memory: 3808kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 0
0 1 0
0 0 0

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
5

result:

ok ok

Test #3:

score: 0
Time Limit Exceeded

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
100
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:


result:


Subtask #2:

score: 8
Accepted

Test #10:

score: 8
Accepted
time: 1ms
memory: 3720kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 0
0 1 0
0 1 1

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
5

result:

ok ok

Test #11:

score: 8
Accepted
time: 0ms
memory: 3744kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 0
0 1 1
0 0 1

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
5

result:

ok ok

Test #12:

score: 8
Accepted
time: 0ms
memory: 4060kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 1
0 0 0
1 1 0

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
5

result:

ok ok

Test #13:

score: 8
Accepted
time: 0ms
memory: 3812kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
1 0 0
1 0 1
0 0 1

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
4

result:

ok ok

Test #14:

score: 8
Accepted
time: 0ms
memory: 4076kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 1
0 0 0
1 0 0

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
6

result:

ok ok

Test #15:

score: 8
Accepted
time: 0ms
memory: 4076kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 1
0 0 1
0 0 0

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
7

result:

ok ok

Test #16:

score: 8
Accepted
time: 1ms
memory: 3764kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 0
0 0 0
0 0 0

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
9

result:

ok ok

Test #17:

score: 8
Accepted
time: 0ms
memory: 3760kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 0
1 0 0
0 1 0

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
6

result:

ok ok

Test #18:

score: 8
Accepted
time: 0ms
memory: 3840kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 1
1 1 1
0 1 1

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
2

result:

ok ok

Test #19:

score: 8
Accepted
time: 0ms
memory: 4060kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
0 0 1
1 0 1
0 1 1

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
3

result:

ok ok

Test #20:

score: 8
Accepted
time: 0ms
memory: 3720kb

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
3
1 0 1
0 0 0
1 0 0

output:

xlqtkQVzqzbOJxjzxlqsyVrlM2kqlbK0
OK
6

result:

ok ok

Subtask #3:

score: 0
Memory Limit Exceeded

Dependency #2:

100%
Accepted

Test #21:

score: 0
Memory Limit Exceeded

input:

R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L
7
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
1 0 0 0 0 1 0
0 0 0 0 0 0 0

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%