답안 #937548

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
937548 2024-03-04T08:24:49 Z Wansur 축구 경기장 (IOI23_soccer) C++17
3.5 / 100
570 ms 419156 KB
#include <bits/stdc++.h>
#define f first
#define s second
#define ent '\n'

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")

typedef long long ll;
using namespace std;
struct seg{
    int m1,m2,sum,cnt;
};

const string out[2]={"NO\n","YES\n"};

const ll dx[]={0,1,0,-1,-1,1,1,-1};
const ll dy[]={1,0,-1,0,-1,1,-1,1};
const int mod=998244353;
const int md=1e9+7;
const int mx=2e3+12;
const bool T=0;

bool used[2001][2001];
int n;

void dfs(int x,int y){
    used[x][y]=1;
    for(int i=0;i<4;i++){
        int x1=dx[i]+x,y1=dy[i]+y;
        if(min(x1,y1)>=0 && max(x1,y1)<n && !used[x1][y1]){
            dfs(x1,y1);
        }
    }
}

int biggest_stadium(int N, vector<vector<int>> a){
    int sum=0;
    n=N;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            sum+=!a[i][j];
            if(a[i][j]){
                used[i][j]=1;
            }
        }
    }
    bool ok=0;
    int pos=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(!used[i][j]){
                pos=i;
                if(ok)return 0;
                ok=1;
                dfs(i,j);
            }
        }
    }
    int l=-1,r=-1;
    bool sg=0;
    vector<pair<int,int>> v;
    for(int i=pos;i<n;i++){
        int tl=-1,tr=-1,sum=0;
        for(int j=0;j<n;j++){
            if(!a[i][j]) {
                ok = 1;
                if(tl==-1){
                    tl=j;
                }
                tr=j;
                sum++;
            }
        }
        if(tl==-1)break;
        if(l==-1){
            l=tl,r=tr;
        }
        if(!(l<=tl && tr<=r || tl<=l && r<=tr) || sum!=tr-tl+1){
            return 0;
        }
        if(tl<=l && r<=tr){
            if(sg)return 0;
        }
        else{
            sg=1;
        }
        l=tl,r=tr;
        v.push_back({tl,tr});
    }
    sort(v.begin(),v.end(),[](pair<int,int> a,pair<int,int> b){
        return a.s-a.f>b.s-b.f;
    });
    l=v[0].f,r=v[0].s;
    for(auto [tl,tr]: v){
        if(tl < l || tr > r){
            return 0;
        }
        l=tl, r=tr;
    }
    return sum;
}

Compilation message

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:79:20: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   79 |         if(!(l<=tl && tr<=r || tl<=l && r<=tr) || sum!=tr-tl+1){
      |              ~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 448 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Partially correct 0 ms 344 KB partial
7 Partially correct 2 ms 1636 KB partial
8 Partially correct 42 ms 28556 KB partial
9 Partially correct 570 ms 419156 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 448 KB ok
3 Partially correct 1 ms 444 KB partial
4 Partially correct 0 ms 348 KB partial
5 Partially correct 0 ms 348 KB partial
6 Partially correct 0 ms 348 KB partial
7 Partially correct 1 ms 348 KB partial
8 Correct 0 ms 396 KB ok
9 Correct 1 ms 348 KB ok
10 Partially correct 0 ms 348 KB partial
11 Partially correct 0 ms 348 KB partial
12 Partially correct 1 ms 348 KB partial
13 Correct 0 ms 348 KB ok
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 448 KB ok
4 Partially correct 1 ms 444 KB partial
5 Partially correct 0 ms 348 KB partial
6 Partially correct 0 ms 348 KB partial
7 Partially correct 0 ms 348 KB partial
8 Partially correct 1 ms 348 KB partial
9 Correct 0 ms 396 KB ok
10 Correct 1 ms 348 KB ok
11 Partially correct 0 ms 348 KB partial
12 Partially correct 0 ms 348 KB partial
13 Partially correct 1 ms 348 KB partial
14 Correct 0 ms 348 KB ok
15 Partially correct 1 ms 348 KB partial
16 Partially correct 0 ms 348 KB partial
17 Partially correct 0 ms 348 KB partial
18 Partially correct 0 ms 348 KB partial
19 Partially correct 0 ms 348 KB partial
20 Incorrect 0 ms 348 KB wrong
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 448 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Partially correct 1 ms 444 KB partial
7 Partially correct 0 ms 348 KB partial
8 Partially correct 0 ms 348 KB partial
9 Partially correct 0 ms 348 KB partial
10 Partially correct 1 ms 348 KB partial
11 Correct 0 ms 396 KB ok
12 Correct 1 ms 348 KB ok
13 Partially correct 0 ms 348 KB partial
14 Partially correct 0 ms 348 KB partial
15 Partially correct 1 ms 348 KB partial
16 Correct 0 ms 348 KB ok
17 Partially correct 1 ms 348 KB partial
18 Partially correct 0 ms 348 KB partial
19 Partially correct 0 ms 348 KB partial
20 Partially correct 0 ms 348 KB partial
21 Partially correct 0 ms 348 KB partial
22 Incorrect 0 ms 348 KB wrong
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 448 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Partially correct 1 ms 444 KB partial
7 Partially correct 0 ms 348 KB partial
8 Partially correct 0 ms 348 KB partial
9 Partially correct 0 ms 348 KB partial
10 Partially correct 1 ms 348 KB partial
11 Correct 0 ms 396 KB ok
12 Correct 1 ms 348 KB ok
13 Partially correct 0 ms 348 KB partial
14 Partially correct 0 ms 348 KB partial
15 Partially correct 1 ms 348 KB partial
16 Correct 0 ms 348 KB ok
17 Partially correct 1 ms 348 KB partial
18 Partially correct 0 ms 348 KB partial
19 Partially correct 0 ms 348 KB partial
20 Partially correct 0 ms 348 KB partial
21 Partially correct 0 ms 348 KB partial
22 Incorrect 0 ms 348 KB wrong
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 448 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Partially correct 0 ms 344 KB partial
8 Partially correct 2 ms 1636 KB partial
9 Partially correct 42 ms 28556 KB partial
10 Partially correct 570 ms 419156 KB partial
11 Partially correct 1 ms 444 KB partial
12 Partially correct 0 ms 348 KB partial
13 Partially correct 0 ms 348 KB partial
14 Partially correct 0 ms 348 KB partial
15 Partially correct 1 ms 348 KB partial
16 Correct 0 ms 396 KB ok
17 Correct 1 ms 348 KB ok
18 Partially correct 0 ms 348 KB partial
19 Partially correct 0 ms 348 KB partial
20 Partially correct 1 ms 348 KB partial
21 Correct 0 ms 348 KB ok
22 Partially correct 1 ms 348 KB partial
23 Partially correct 0 ms 348 KB partial
24 Partially correct 0 ms 348 KB partial
25 Partially correct 0 ms 348 KB partial
26 Partially correct 0 ms 348 KB partial
27 Incorrect 0 ms 348 KB wrong
28 Halted 0 ms 0 KB -