Submission #955062

# Submission time Handle Problem Language Result Execution time Memory
955062 2024-03-29T10:02:43 Z Abito Cultivation (JOI17_cultivation) C++17
0 / 100
1 ms 600 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};
bool vis[N][N];
bool ok(int x,int y){
    return x && y && x<=r && y<=c && !vis[x][y];
}
bool cmp(set<pair<int,int>> x,set<pair<int,int>> y){
    return x.size()<y.size();
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>r>>c>>n;vector<pair<int,int>> v;
    for (int i=1;i<=n;i++){
        int x,y;
        cin>>x>>y;
        v.pb({x,y});
        vis[x][y]=1;
    }int ans=0;
    while (v.size()<r*c){
        set<pair<int,int>> s[4];
        for (auto u:v){
            int x=u.F,y=u.S;
            for (int i=0;i<4;i++){
                int nx=x+mvx[i],ny=y+mvy[i];
                if (!ok(nx,ny)) continue;
                s[i].ep({nx,ny});
            }
        }
        sort(s,s+4,cmp);
        for (auto u:s[3]) v.pb(u);
        ans++;
    }cout<<ans<<endl;
    return 0;
}

Compilation message

cultivation.cpp: In function 'int32_t main()':
cultivation.cpp:33:20: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |     while (v.size()<r*c){
      |            ~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 600 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 600 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 600 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 600 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -