답안 #1018238

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018238 2024-07-09T17:03:14 Z tmarcinkevicius 축구 경기장 (IOI23_soccer) C++17
0 / 100
0 ms 596 KB
#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define f first
#define s second

int biggest_stadium(int N, vector<vector<int>> F)
{
    vector<vector<int>> prefixLine(N), prefixCol(N);

    for (int i = 0; i < N; i++)
    {
        prefixLine[i] = vector<int>(N, 0);

        prefixLine[i][0] = F[i][0];

        for (int j = 1; j < N; j++)
        {
            prefixLine[i][j] = prefixLine[i][j - 1] + F[i][j];
        }
    }

    for (int i = 0; i < N; i++)
    {
        prefixCol[i] = vector<int>(N, 0);

        prefixCol[i][0] = F[0][i];

        for (int j = 1; j < N; j++)
        {
            prefixCol[i][j] = prefixCol[i][j - 1] + F[j][i];
        }
    }

    set<pii> freeCells;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (F[i][j] == 0)
            {
                freeCells.insert({i, j});
            }
        }
    }

    bool possible = true;
    for (pii p1 : freeCells)
    {
        for (pii p2 : freeCells)
        {
            if (p1 == p2)
                continue;

            if (p1.f == p2.f)
            {
                int sum = prefixLine[p1.f][max(p1.s, p2.s)] - prefixLine[p1.f][min(p1.s, p2.s)];
                if (sum != 0)
                {
                    cout << "{" << p1.f << ", " << p1.s << "} - {" << p2.f << ", " << p2.s << "}\n";
                    possible = false;
                    break;
                }
            }
            else if (p1.s == p2.s)
            {
                int sum = prefixCol[p1.s][max(p1.f, p2.f)] - prefixCol[p1.s][min(p1.f, p2.f)];
                if (sum != 0)
                {
                    cout << "{" << p1.f << ", " << p1.s << "} - {" << p2.f << ", " << p2.s << "}\n";
                    possible = false;
                    break;
                }
            }
            else
            {
                // cout << "check {" << p1.f << ", " << p1.s << "} - {" << p2.f << ", " << p2.s << "}\n";
                int sum1 = prefixLine[p1.f][max(p1.s, p2.s)] + prefixCol[p2.s][max(p1.f, p2.f)];
                int sum2 = prefixLine[p2.f][max(p1.s, p2.s)] + prefixCol[p1.s][max(p1.f, p2.f)];

                if (min(p1.s, p2.s) > 0)
                {
                    sum1 -= prefixLine[p1.f][min(p1.s, p2.s) - 1];
                    sum2 -= prefixLine[p2.f][min(p1.s, p2.s) - 1];
                }
                if (min(p1.f, p2.f) > 0)
                {
                    sum1 -= prefixCol[p2.s][min(p1.f, p2.f) - 1];
                    sum2 -= prefixCol[p1.s][min(p1.f, p2.f) - 1];
                }

                // cout << "sums: " << sum1 << " " << sum2 << '\n';
                // cout << "s1: " << prefixLine[p1.f][max(p1.s, p2.s)] - prefixLine[p1.f][min(p1.s, p2.s)] << '\n';

                if (sum1 != 0 && sum2 != 0)
                {
                    // cout << "{" << p1.f << ", " << p1.s << "} - {" << p2.f << ", " << p2.s << "}\n";
                    possible = false;
                    break;
                }
            }
        }

        if (!possible)
            break;
    }

    if (possible)
    {
        return freeCells.size();
    }
    else
    {
        return 0;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 344 KB ok
5 Correct 0 ms 348 KB ok
6 Incorrect 0 ms 348 KB Possible tampering with the output
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Incorrect 0 ms 596 KB Possible tampering with the output
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Possible tampering with the output
2 Halted 0 ms 0 KB -