CSES - Datatähti 2024 loppu - Results
Submission details
Task:Retkeily
Sender:DualRed
Submission time:2024-01-20 15:32:03 +0200
Language:C++ (C++20)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:30:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   30 |         return;
      |         ^~~~~~

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;


int main(){
    int n, m;
    cin >> n >> m;

    if(n <= 1000 && m <= 1000) {
        vector<pair<int, int>> occ(n), fr(m);
        for(int i = 0; i < n; i++){
            int x, y; cin >> x >> y;
            occ[i] = make_pair(x, y);
        }
        for(int i = 0; i < m; i++){
            int x, y; cin >> x >> y;
            fr[i] = make_pair(x, y);
        }

        int ans = 0;
        for(int i = 0; i < m; i++){
            int mind = 1 << 30;
            for(int j = 0; j < n; j++){
                mind = min(mind, abs(occ[j].first - fr[i].first) + abs(occ[j].second - fr[i].second));
            }
            ans = max(ans, mind);
        }
        cout << ans << endl;
        return;
    }

    

    vector<pair<int, int>> xord, yord, fr(m);
    for(int i = 0; i < n; i++){
        int x, y; cin >> x >> y;
        xord.push_back(make_pair(x, y));
        yord.push_back(make_pair(y, x));
    }
    for(int i = 0; i < m; i++){
        int x, y; cin >> x >> y;
        fr[i] = make_pair(x, y);
    }
    sort(xord.begin(), xord.end());
    sort(yord.begin(), yord.end());

    int ans = 0;
    for(auto[x, y] : fr){
        int mind = 1 << 30;
        int xl = lower_bound(xord.begin(), xord.end(), make_pair(x - 10, 0)) - xord.begin();
        int xr = upper_bound(xord.begin(), xord.end(), make_pair(x + 10, 1 << 30)) - xord.begin();
        int yl = lower_bound(yord.begin(), yord.end(), make_pair(y - 10, 0)) - yord.begin();
        int yr = upper_bound(yord.begin(), yord.end(), make_pair(y + 10, 1 << 30)) - yord.begin();
        if(xr - xl < yr - yl){
            for(int i = xl; i  < xr; i++){
                mind = min(mind, abs(x - xord[i].first) + abs(y - xord[i].second));
            }
        }
        else{
            for(int i = yl; i  < yr; i++){
                mind = min(mind, abs(x - yord[i].second) + abs(y - yord[i].first));
            }
        }
        ans = max(ans, mind);
    }
    cout << ans << endl;



}