답안 #939212

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
939212 2024-03-06T06:50:55 Z WanWan 축구 경기장 (IOI23_soccer) C++17
7.5 / 100
18 ms 5468 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
const int MAXN = 2005;
const int inf=1000000500ll;
const long long oo =1000000000000000500ll;
const int MOD = (int)1e9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> pi; 
vector<int> row[MAXN], col[MAXN];
vector<int> rowh[MAXN],colh[MAXN];
struct ufds_{
    int p[MAXN];
    ufds_(){
        iota(p,p+MAXN,0);
    }
    int find(int x){
        if(x==p[x])return x;
        else return p[x]=find(p[x]);
    }
    void merge(int x, int y){
        x=find(x);y=find(y);
        p[y]=x;
    }
}ufds;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
int n;
int get(int x, int y){
    return x*n+y;
}
int biggest_stadium(int N, std::vector<std::vector<int>> V)
{
    n=N;
    int cnt=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(V[i][j] == 0){
                ++cnt;
                for(int k=0;k<3;k++){
                    int nx=i+dx[k];
                    int ny=j+dy[k];
                    if(nx<0 || nx>=n ||ny<0 || ny>=n || V[nx][ny])continue;
                    ufds.merge(get(i,j),get(nx,ny));
                }
            }
        }
    }
    unordered_set<int>os;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(V[i][j] == 0)os.insert(ufds.find(get(i,j)));
        }
    }
    if(os.size() > 1)return 0;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(V[i][j])row[i].push_back(j);
            else rowh[i].push_back(j);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(V[i][j])col[j].push_back(i);
            else colh[j].push_back(i);
        }
    }
    for(int i=0;i<n;i++){
        if(rowh[i].empty())continue;
        int st=rowh[i][0];
        int en=rowh[i].back();
        if(en-st+1 != rowh[i].size()){
            return 0;
        }
    }
     for(int j=0;j<n;j++){
        if(colh[j].empty())continue;
        int st=colh[j][0];
        int en=colh[j].back();
        if(en-st+1 != colh[j].size()){
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(V[i][j] == 0){
                if(upper_bound(row[i].begin(),row[i].end(),j) != row[i].end() && upper_bound(col[j].begin(),col[j].end(),i) != col[j].end()){
                    int nx=*upper_bound(row[i].begin(),row[i].end(),j);
                    int ny=*upper_bound(col[j].begin(),col[j].end(),i);
                    if(V[nx][ny] == 0)return 0;
                }
                if(upper_bound(row[i].begin(),row[i].end(),j) != row[i].end() && lower_bound(col[j].begin(),col[j].end(),i) != col[j].begin()){
                    int nx=*upper_bound(row[i].begin(),row[i].end(),j);
                    int ny=*prev(lower_bound(col[j].begin(),col[j].end(),i));
                    if(V[nx][ny] == 0)return 0;
                }
                if(lower_bound(row[i].begin(),row[i].end(),j) != row[i].begin() && upper_bound(col[j].begin(),col[j].end(),i) != col[j].end()){
                    int nx=*prev(lower_bound(row[i].begin(),row[i].end(),j));
                    int ny=*upper_bound(col[j].begin(),col[j].end(),i);
                    if(V[nx][ny] == 0)return 0;
                }
                if(lower_bound(row[i].begin(),row[i].end(),j) != row[i].begin() && lower_bound(col[j].begin(),col[j].end(),i) != col[j].begin()){
                    int nx=*prev(lower_bound(row[i].begin(),row[i].end(),j));
                    int ny=*prev(lower_bound(col[j].begin(),col[j].end(),i));
                    if(V[nx][ny] == 0)return 0;
                }
            }
        }
    }


    return cnt;
}

Compilation message

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:80:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |         if(en-st+1 != rowh[i].size()){
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~
soccer.cpp:88:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |         if(en-st+1 != colh[j].size()){
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 600 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB ok
2 Correct 0 ms 604 KB ok
3 Correct 0 ms 604 KB ok
4 Correct 0 ms 604 KB ok
5 Correct 0 ms 600 KB ok
6 Partially correct 0 ms 604 KB partial
7 Partially correct 1 ms 604 KB partial
8 Runtime error 18 ms 5468 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB ok
2 Correct 0 ms 604 KB ok
3 Partially correct 1 ms 600 KB partial
4 Partially correct 0 ms 604 KB partial
5 Partially correct 0 ms 604 KB partial
6 Partially correct 0 ms 604 KB partial
7 Partially correct 0 ms 600 KB partial
8 Correct 1 ms 604 KB ok
9 Correct 0 ms 604 KB ok
10 Partially correct 0 ms 604 KB partial
11 Partially correct 0 ms 604 KB partial
12 Partially correct 0 ms 604 KB partial
13 Correct 0 ms 604 KB ok
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 600 KB partial
2 Correct 1 ms 604 KB ok
3 Correct 0 ms 604 KB ok
4 Partially correct 1 ms 600 KB partial
5 Partially correct 0 ms 604 KB partial
6 Partially correct 0 ms 604 KB partial
7 Partially correct 0 ms 604 KB partial
8 Partially correct 0 ms 600 KB partial
9 Correct 1 ms 604 KB ok
10 Correct 0 ms 604 KB ok
11 Partially correct 0 ms 604 KB partial
12 Partially correct 0 ms 604 KB partial
13 Partially correct 0 ms 604 KB partial
14 Correct 0 ms 604 KB ok
15 Partially correct 1 ms 816 KB partial
16 Partially correct 1 ms 604 KB partial
17 Partially correct 1 ms 604 KB partial
18 Partially correct 1 ms 604 KB partial
19 Partially correct 0 ms 604 KB partial
20 Correct 1 ms 604 KB ok
21 Correct 0 ms 600 KB ok
22 Partially correct 1 ms 604 KB partial
23 Partially correct 1 ms 420 KB partial
24 Partially correct 0 ms 604 KB partial
25 Partially correct 0 ms 604 KB partial
26 Partially correct 1 ms 604 KB partial
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 600 KB partial
2 Correct 1 ms 604 KB ok
3 Correct 0 ms 604 KB ok
4 Correct 0 ms 604 KB ok
5 Correct 0 ms 604 KB ok
6 Partially correct 1 ms 600 KB partial
7 Partially correct 0 ms 604 KB partial
8 Partially correct 0 ms 604 KB partial
9 Partially correct 0 ms 604 KB partial
10 Partially correct 0 ms 600 KB partial
11 Correct 1 ms 604 KB ok
12 Correct 0 ms 604 KB ok
13 Partially correct 0 ms 604 KB partial
14 Partially correct 0 ms 604 KB partial
15 Partially correct 0 ms 604 KB partial
16 Correct 0 ms 604 KB ok
17 Partially correct 1 ms 816 KB partial
18 Partially correct 1 ms 604 KB partial
19 Partially correct 1 ms 604 KB partial
20 Partially correct 1 ms 604 KB partial
21 Partially correct 0 ms 604 KB partial
22 Correct 1 ms 604 KB ok
23 Correct 0 ms 600 KB ok
24 Partially correct 1 ms 604 KB partial
25 Partially correct 1 ms 420 KB partial
26 Partially correct 0 ms 604 KB partial
27 Partially correct 0 ms 604 KB partial
28 Partially correct 1 ms 604 KB partial
29 Partially correct 0 ms 636 KB partial
30 Partially correct 1 ms 600 KB partial
31 Partially correct 1 ms 600 KB partial
32 Partially correct 1 ms 604 KB partial
33 Partially correct 1 ms 604 KB partial
34 Incorrect 1 ms 604 KB wrong
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 600 KB partial
2 Correct 1 ms 604 KB ok
3 Correct 0 ms 604 KB ok
4 Correct 0 ms 604 KB ok
5 Correct 0 ms 604 KB ok
6 Partially correct 1 ms 600 KB partial
7 Partially correct 0 ms 604 KB partial
8 Partially correct 0 ms 604 KB partial
9 Partially correct 0 ms 604 KB partial
10 Partially correct 0 ms 600 KB partial
11 Correct 1 ms 604 KB ok
12 Correct 0 ms 604 KB ok
13 Partially correct 0 ms 604 KB partial
14 Partially correct 0 ms 604 KB partial
15 Partially correct 0 ms 604 KB partial
16 Correct 0 ms 604 KB ok
17 Partially correct 1 ms 816 KB partial
18 Partially correct 1 ms 604 KB partial
19 Partially correct 1 ms 604 KB partial
20 Partially correct 1 ms 604 KB partial
21 Partially correct 0 ms 604 KB partial
22 Correct 1 ms 604 KB ok
23 Correct 0 ms 600 KB ok
24 Partially correct 1 ms 604 KB partial
25 Partially correct 1 ms 420 KB partial
26 Partially correct 0 ms 604 KB partial
27 Partially correct 0 ms 604 KB partial
28 Partially correct 1 ms 604 KB partial
29 Partially correct 0 ms 636 KB partial
30 Partially correct 1 ms 600 KB partial
31 Partially correct 1 ms 600 KB partial
32 Partially correct 1 ms 604 KB partial
33 Partially correct 1 ms 604 KB partial
34 Incorrect 1 ms 604 KB wrong
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 600 KB partial
2 Correct 1 ms 604 KB ok
3 Correct 0 ms 604 KB ok
4 Correct 0 ms 604 KB ok
5 Correct 0 ms 604 KB ok
6 Correct 0 ms 600 KB ok
7 Partially correct 0 ms 604 KB partial
8 Partially correct 1 ms 604 KB partial
9 Runtime error 18 ms 5468 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -