답안 #1035488

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1035488 2024-07-26T11:31:55 Z Abito Rectangles (IOI19_rect) C++17
13 / 100
614 ms 573792 KB
#include "rect.h"
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
using namespace std;
const int N=2505;
int n,m,a[N][N],mvx[]={1,0,-1,0},mvy[]={0,1,0,-1};
bool vis[N][N];
bool ok(int x,int y){
    return x>=1 && x<=n && y>=1 && y<=m && !vis[x][y] && !a[x][y];
}
vector<pair<int,int>> s;
void dfs(int x,int y){
    vis[x][y]=1;
    s.pb({x,y});
    for (int i=0;i<4;i++){
        int nx=mvx[i]+x,ny=mvy[i]+y;
        if (ok(nx,ny)) dfs(nx,ny);
    }return;
}
long long count_rectangles(vector<vector<int>> v){
    n=v.size();
    m=v[0].size();
    if (n<=2 || m<=2) return 0LL;
    long long ans=0;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++) a[i][j]=v[i-1][j-1];
    }
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            if (a[i][j] || vis[i][j]) continue;
            s.clear();
            dfs(i,j);
            //for (auto u:s) cout<<u.F<<' '<<u.S<<endl;
            //cout<<endl;
            int mnx=INT_MAX,mxx=INT_MIN,mny=INT_MAX,mxy=INT_MIN;
            for (auto u:s){
                mnx=min(mnx,u.F);
                mny=min(mny,u.S);
                mxx=max(mxx,u.F);
                mxy=max(mxy,u.S);
            }
            if (mxx==n || mxy==m || mnx==1 || mny==1) continue;
            //cout<<mxx<<' '<<mnx<<' '<<mxy<<' '<<mny<<endl;
            if ((mxx-mnx+1)*(mxy-mny+1)==s.size()) ans++;
        }
    }
    return ans;
}

Compilation message

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:46:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             if ((mxx-mnx+1)*(mxy-mny+1)==s.size()) ans++;
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 103 ms 43532 KB Output is correct
3 Correct 215 ms 91908 KB Output is correct
4 Correct 206 ms 92244 KB Output is correct
5 Correct 227 ms 92288 KB Output is correct
6 Correct 243 ms 201116 KB Output is correct
7 Correct 534 ms 484008 KB Output is correct
8 Correct 614 ms 573792 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -