Submission #1074450

# Submission time Handle Problem Language Result Execution time Memory
1074450 2024-08-25T10:34:50 Z anango Soccer Stadium (IOI23_soccer) C++17
0 / 100
1 ms 348 KB
#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
vector<vector<int>> pref;
vector<vector<signed>> field;

int INF = 1LL<<30;

int query(int a, int b, int c, int d) {
    if (a<c) swap(a,c);
    if (b<d) swap(b,d);
    int su=0;
    for (int i=a; i<=b; i++) {
        for (int j=c; j<=d; j++) {
            su+=field[i][j];
        }
    }
    return su;
    return pref[c+1][d+1]-pref[a][d+1]-pref[c+1][b]+pref[a][b];
}

signed biggest_stadium(signed N, vector<vector<signed>> F) {
    //the stadium is valid iff for every pair of cells (a,b) and (c,d), 
    //everything in the paths (a,b) to (a,d) to (c,d) is inside
    //or everything in the paths (a,b) to (a,c) to (c,d) is inside
    n=N;
    field=F;
    pref=vector<vector<int>>(n+1,vector<int>(n+1,0));
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            pref[i+1][j+1] = pref[i+1][j]+pref[i][j+1]-pref[i][j]+F[i][j];
        }
    }
    for (int a=0; a<n; a++) {
        for (int b=0; b<n; b++) {
            for (int c=0; c<n; c++) {
                for (int d=0; d<n; d++) {
                    if (F[a][b]==1 || F[c][d]==1) continue;
                    //everything in the paths (a,b) to (a,d) to (c,d) is inside
                    if (query(a,b,a,d)==0 && query(a,d,c,d)==0) continue;
                    //or everything in the paths (a,b) to (a,c) to (c,d) is inside
                    if (query(a,b,a,c)==0 && query(a,c,c,d)==0) continue;
                    return INF;
                }
            }
        }
    }
    //cout << "jambloat " << pref[n][n] << endl;
    return n*n-pref[n][n];
}
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB ok
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB ok
2 Incorrect 0 ms 348 KB wrong
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
2 Correct 1 ms 348 KB ok
3 Incorrect 0 ms 348 KB wrong
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
2 Correct 1 ms 348 KB ok
3 Incorrect 0 ms 348 KB wrong
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
2 Correct 1 ms 348 KB ok
3 Incorrect 0 ms 348 KB wrong
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 348 KB partial
2 Correct 1 ms 348 KB ok
3 Incorrect 0 ms 348 KB wrong
4 Halted 0 ms 0 KB -