Submission #1244310

#TimeUsernameProblemLanguageResultExecution timeMemory
1244310cpdreamer축구 경기장 (IOI23_soccer)C++17
25 / 100
269 ms31908 KiB
#include "soccer.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long INF = 1e18+1;
typedef long long ll;
const ll MOD =  1e9+7;
#define P pair
#define S second
#define pb push_back
#define all(v) v.begin(), v.end()
#define V vector
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

bool cus(P<int,int>a,P<int,int>b) {
    return a.second-a.first>b.second-b.first;
}
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
    V<P<int,int>>row,col;
    int c=0;
    for (int i=0;i<N;i++) {
        for (int j=0;j<N;j++) {
            F[i][j]=!F[i][j];
            if (F[i][j]) {
                c++;
            }
        }
    }
    for (int i=0;i<N;i++) {
        V<int>v;
        for (int j=0;j<N;j++) {
            if (F[i][j]) {
                v.pb(j);
            }
        }
        for (int j=0;j<(int)v.size()-1;j++) {
            if (v[j+1]-v[j]!=1) {
                return 0;
            }
        }
        int l=-1,r=-1;
        for (int j=0;j<N;j++) {
            if (F[i][j]) {
                l=j;
                break;
            }
        }
        for (int j=0;j<N;j++) {
            if (F[i][j]) {
                r=j;
            }
        }
        if (l!=-1 )row.pb({l,r});
    }
    for (int i=0;i<N;i++) {
        V<int>v;
        for (int j=0;j<N;j++) {
            if (F[j][i]) {
                v.pb(j);
            }
        }
        for (int j=0;j<(int)v.size()-1;j++) {
            if (v[j+1]-v[j]!=1) {
                return 0;
            }
        }
        int l=-1,r=-1;
        for (int j=0;j<N;j++) {
            if (F[j][i]) {
                l=j;
                break;
            }
        }
        for (int j=0;j<N;j++) {
            if (F[j][i]) {
                r=j;
            }
        }
        if (l!=-1 )col.pb({l,r});
    }
    sort(all(row),cus);
    sort(all(col),cus);
    for (int i=0;i<(int)row.size()-1;i++) {
        if (row[i].first>row[i+1].first || row[i].second<row[i+1].second)return 0;
    }
    for (int i=0;i<(int)col.size()-1;i++) {
        if (col[i].first>col[i+1].first || col[i].second<col[i+1].second)return 0;
    }
    return c;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...