답안 #955068

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955068 2024-03-29T10:14:52 Z Abito Cultivation (JOI17_cultivation) C++17
5 / 100
2000 ms 246096 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
//#define int long long
#define ll long long
typedef unsigned long long ull;
using namespace std;
const int N=305;
int n,r,c,mvx[]={0,1,0,-1},mvy[]={1,0,-1,0};
int rec(vector<vector<bool>> v){
    int s=0;
    for (int i=0;i<r;i++) for (int j=0;j<c;j++) s+=v[i][j];
    if (s==r*c) return 0;
    int ans=INT_MAX;
    for (int k=0;k<4;k++){
        set<pair<int,int>> b;
        for (int i=0;i<r;i++){
            for (int j=0;j<c;j++){
                if (!v[i][j]) continue;
                int x=i+mvx[k],y=j+mvy[k];
                if (x<0 || x>=r || y<0 || y>=c) continue;
                if (v[x][y]) continue;
                b.ep({x,y});
            }
        }
        if (b.empty()) continue;
        for (auto u:b) v[u.F][u.S]=1;
        ans=min(ans,rec(v)+1);
        for (auto u:b) v[u.F][u.S]=0;
    }return ans;
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    vector<vector<bool>> v;
    cin>>r>>c;
    for (int i=0;i<r;i++){
        vector<bool> b;
        for (int j=0;j<c;j++) b.pb(0);
        v.pb(b);
    }
    cin>>n;
    for (int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        v[--x][--y]=1;
    }
    cout<<rec(v);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 3 ms 452 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 3 ms 452 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Execution timed out 2052 ms 480 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 3 ms 452 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Execution timed out 2052 ms 480 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2062 ms 246096 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2062 ms 246096 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 3 ms 452 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Execution timed out 2052 ms 480 KB Time limit exceeded
18 Halted 0 ms 0 KB -