CSES - Aalto Competitive Programming 2024 - wk5 - Wed - Results
Submission details
Task:Manhattan sightseeing
Sender:aalto2024f_002
Submission time:2024-10-02 17:28:00 +0300
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.00 sdetails
#11ACCEPTED0.00 sdetails
#12ACCEPTED0.00 sdetails
#13ACCEPTED0.00 sdetails
#14ACCEPTED0.00 sdetails
#15ACCEPTED0.00 sdetails
#16ACCEPTED0.00 sdetails
#17ACCEPTED0.00 sdetails
#18ACCEPTED0.00 sdetails
#19ACCEPTED0.00 sdetails
#20ACCEPTED0.00 sdetails
#21ACCEPTED0.00 sdetails
#22ACCEPTED0.00 sdetails
#23ACCEPTED0.00 sdetails
#24ACCEPTED0.00 sdetails
#25ACCEPTED0.00 sdetails
#26ACCEPTED0.00 sdetails
#27ACCEPTED0.00 sdetails
#28ACCEPTED0.00 sdetails
#29ACCEPTED0.00 sdetails
#30ACCEPTED0.00 sdetails
#31ACCEPTED0.00 sdetails
#32ACCEPTED0.00 sdetails
#33ACCEPTED0.00 sdetails
#34ACCEPTED0.00 sdetails
#35ACCEPTED0.00 sdetails
#36ACCEPTED0.00 sdetails
#37ACCEPTED0.00 sdetails
#380.00 sdetails
#390.00 sdetails
#400.00 sdetails
#410.00 sdetails
#420.00 sdetails
#430.00 sdetails
#440.00 sdetails
#450.00 sdetails
#460.00 sdetails
#470.00 sdetails
#480.00 sdetails
#490.00 sdetails
#500.00 sdetails
#510.00 sdetails
#520.00 sdetails
#530.00 sdetails
#540.00 sdetails
#550.00 sdetails
#560.00 sdetails
#570.00 sdetails
#580.00 sdetails
#590.00 sdetails
#600.00 sdetails
#610.00 sdetails
#620.00 sdetails
#630.00 sdetails
#640.00 sdetails
#650.00 sdetails
#660.00 sdetails
#670.00 sdetails
#680.05 sdetails
#690.05 sdetails
#700.05 sdetails
#710.05 sdetails
#720.05 sdetails
#730.05 sdetails
#740.05 sdetails
#750.05 sdetails
#760.05 sdetails
#770.05 sdetails

Compiler report

input/code.cpp: In function 'void solve()':
input/code.cpp:54:20: warning: statement has no effect [-Wunused-value]
   54 | #define debug(...) 42
      |                    ^~
input/code.cpp:130:5: note: in expansion of macro 'debug'
  130 |     debug(mxdist(ansx, ansy));
      |     ^~~~~
input/code.cpp:54:20: warning: statement has no effect [-Wunused-value]
   54 | #define debug(...) 42
      |                    ^~
input/code.cpp:131:5: note: in expansion of macro 'debug'
  131 |     debug(mxdist(500000002, 500000001));
      |     ^~~~~
input/code.cpp:54:20: warning: statement has no effect [-Wunused-value]
   54 | #define debug(...) 42
      |                    ^~
input/code.cpp:132:5: note: in expansion of macro 'debug'
  132 |     debug(mxdist(cx, cy));
      |     ^~~~~

Code

#include <algorithm>
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define int long long

string to_string(string s) {
    return '"' + s + '"';
}
 
string to_string(const char* s) {
    return to_string((string) s);
}
 
string to_string(bool b) {
    return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
 
void debug_out() {
    cerr << endl;
}
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 1e5 + 5;
const int INF = 1e9;

int n, x[N], y[N];

void solve() {
    cin >> n;
    int mxx = 0, mnx = INF, mxy = 0, mny = INF;    
    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i];
        mxx = max(mxx, x[i]);
        mxy = max(mxy, y[i]);
        mnx = min(mnx, x[i]);
        mny = min(mny, x[i]);
    }

    int cx = x[1], cy = y[1];
    for (int i = 2; i <= n; i++) {
        cx = (cx + x[i]) / 2;
        cy = (cy + y[i]) / 2;
    }

    auto mxdist = [&](int posx, int posy) -> int {
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            ans = max(ans, abs(posx - x[i]) + abs(posy - y[i]));
        }
        return ans;
    };

    // int best = mxdist(cx, cy), ansx = cx, ansy = cy;
    // for (int xx = cx - 5; xx <= cx + 5; xx++) {
    //     for (int yy = cy - 5; yy <= cy + 5; yy++) {
    //         int cur = mxdist(xx, yy);
    //         if (cur < best) {
    //             best = cur;
    //             ansx = xx;
    //             ansy = yy;
    //         }
    //     }   
    // }

    cx = (mnx + mxx) / 2;
    cy = (mny + mxy) / 2;
    
    int best = mxdist(cx, cy), ansx = cx, ansy = cy;
    for (int xx = cx - 5; xx <= cx + 5; xx++) {
        for (int yy = cy - 5; yy <= cy + 5; yy++) {
            int cur = mxdist(xx, yy);
            if (cur < best) {
                best = cur;
                ansx = xx;
                ansy = yy;
            }
        }   
    }


    // for (int xx : {mnx, mxx}) {
    //     for (int yy : {mny, mxy}) {
    //         for (int xxx : {mnx, mxx}) {
    //             for (int yyy : {mny, mxy}) {
    //                 int cur = mxdist((xx + xxx) / 2, (yy + yyy) / 2);
    //                 if (cur < best) {
    //                     best = cur;
    //                     ansx = (xx + xxx) / 2;
    //                     ansy = (yy + yyy) / 2;
    //                 }
    //             }
    //         }
    //     }
    // }

    debug(mxdist(ansx, ansy));
    debug(mxdist(500000002, 500000001));
    debug(mxdist(cx, cy));
    cout << ansx << ' ' << ansy << '\n';

    

    // auto calc = [&](int posx) -> int {
    //     int low = mny, high = mxy, ans = -1;
    //     while (low <= high) {
    //         int mid = (low + high) / 2;
    //         if (mxdist(posx, mid) >= mxdist(posx, mid + 1)) {
    //             low = mid + 1;
    //             ans = mid + 1;
    //         } else {
    //             high = mid - 1;
    //             ans = mid;
    //         }
    //     } 
    //     return mxdist(posx, ans);
    // };

    // auto findcalc = [&](int posx) -> int {
    //     int low = mny, high = mxy, ans = -1;
    //     while (low <= high) {
    //         int mid = (low + high) / 2;
    //         if (mxdist(posx, mid) >= mxdist(posx, mid + 1)) {
    //             low = mid + 1;
    //             ans = mid + 1;
    //         } else {
    //             high = mid - 1;
    //             ans = mid;
    //         }
    //     } 
    //     return ans;
    // };

    // int lowx = mnx, highx = mxx, ansx = -1;
    // while (lowx <= highx) {
    //     int midx = (lowx + highx) / 2;
    //     if (calc(midx) >= calc(midx + 1)) {
    //         lowx = midx + 1;
    //         ansx = midx + 1;
    //     } else {
    //         highx = midx - 1;
    //         ansx = midx;
    //     }
    // } 

    // cout << ansx << ' ' << findcalc(ansx) << '\n';
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
            
    int t = 1;
    // cin >> t;

    while (t--) {
        solve();
    }
}

Test details

Test 1

Verdict: ACCEPTED

input
1
7 7

correct output
7 7

user output
7 7

Test 2

Verdict: ACCEPTED

input
1
1 5

correct output
1 5

user output
1 5

Test 3

Verdict: ACCEPTED

input
2
8 1
3 3

correct output
5 2

user output
4 1

Test 4

Verdict: ACCEPTED

input
2
1 5
3 2

correct output
2 3

user output
2 3

Test 5

Verdict: ACCEPTED

input
3
6 3
2 3
6 1

correct output
4 2

user output
4 2

Test 6

Verdict: ACCEPTED

input
3
9 6
3 8
9 4

correct output
6 6

user output
5 5

Test 7

Verdict: ACCEPTED

input
3
8 7
8 6
8 7

correct output
8 6

user output
8 7

Test 8

Verdict: ACCEPTED

input
4
3 6
9 9
7 9
5 1

correct output
6 6

user output
6 6

Test 9

Verdict: ACCEPTED

input
4
3 1
2 9
8 9
6 8

correct output
4 6

user output
5 5

Test 10

Verdict: ACCEPTED

input
4
6 5
8 3
9 3
7 9

correct output
7 5

user output
7 5

Test 11

Verdict: ACCEPTED

input
4
2 8
9 7
5 1
3 7

correct output
5 6

user output
5 6

Test 12

Verdict: ACCEPTED

input
4
5 5
6 3
8 5
2 4

correct output
4 5

user output
4 5

Test 13

Verdict: ACCEPTED

input
4
7 3
8 7
3 2
8 6

correct output
6 4

user output
5 5

Test 14

Verdict: ACCEPTED

input
4
1 3
7 6
2 6
3 4

correct output
3 5

user output
2 6

Test 15

Verdict: ACCEPTED

input
4
7 8
3 1
2 3
3 2

correct output
4 5

user output
4 5

Test 16

Verdict: ACCEPTED

input
4
2 7
9 1
3 5
2 1

correct output
3 2

user output
5 4

Test 17

Verdict: ACCEPTED

input
4
7 7
2 2
7 3
1 8

correct output
4 5

user output
3 5

Test 18

Verdict: ACCEPTED

input
5
5 6
7 8
6 8
5 8
...

correct output
5 7

user output
4 8

Test 19

Verdict: ACCEPTED

input
5
4 9
7 9
1 2
3 9
...

correct output
3 6

user output
4 5

Test 20

Verdict: ACCEPTED

input
5
4 2
1 9
5 9
4 5
...

correct output
3 6

user output
3 6

Test 21

Verdict: ACCEPTED

input
5
5 1
7 8
3 2
5 6
...

correct output
6 4

user output
5 5

Test 22

Verdict: ACCEPTED

input
5
9 9
5 2
9 8
7 6
...

correct output
6 6

user output
5 7

Test 23

Verdict: ACCEPTED

input
5
2 1
8 8
2 4
9 9
...

correct output
5 5

user output
5 5

Test 24

Verdict: ACCEPTED

input
5
9 9
3 2
8 1
1 4
...

correct output
5 5

user output
5 5

Test 25

Verdict: ACCEPTED

input
5
1 3
8 3
4 9
7 5
...

correct output
4 4

user output
5 5

Test 26

Verdict: ACCEPTED

input
5
8 1
9 3
8 4
5 8
...

correct output
6 4

user output
5 3

Test 27

Verdict: ACCEPTED

input
5
1 4
5 5
5 1
2 3
...

correct output
3 3

user output
3 3

Test 28

Verdict: ACCEPTED

input
10
5 6
7 8
6 8
5 8
...

correct output
6 4

user output
6 3

Test 29

Verdict: ACCEPTED

input
10
4 9
7 9
1 2
3 9
...

correct output
3 6

user output
4 5

Test 30

Verdict: ACCEPTED

input
10
4 2
1 9
5 9
4 5
...

correct output
3 5

user output
3 5

Test 31

Verdict: ACCEPTED

input
10
5 1
7 8
3 2
5 6
...

correct output
5 3

user output
5 4

Test 32

Verdict: ACCEPTED

input
10
9 9
5 2
9 8
7 6
...

correct output
5 6

user output
5 6

Test 33

Verdict: ACCEPTED

input
10
2 1
8 8
2 4
9 9
...

correct output
4 6

user output
5 5

Test 34

Verdict: ACCEPTED

input
10
9 9
3 2
8 1
1 4
...

correct output
5 5

user output
5 5

Test 35

Verdict: ACCEPTED

input
10
1 3
8 3
4 9
7 5
...

correct output
4 4

user output
5 5

Test 36

Verdict: ACCEPTED

input
10
8 1
9 3
8 4
5 8
...

correct output
5 4

user output
5 4

Test 37

Verdict: ACCEPTED

input
10
1 4
5 5
5 1
2 3
...

correct output
2 3

user output
3 4

Test 38

Verdict:

input
100
589284012 636562060
767928734 906523441
647212241 921212095
585063857 909729626
...

correct output
485094485 480883850

user output
501432960 499446772

Test 39

Verdict:

input
100
447773962 773442532
122816 137572579
324627123 157577940
253498609 99147813
...

correct output
534004334 480422569

user output
487859910 498013780

Test 40

Verdict:

input
100
468145963 198730372
27838076 590195590
467423861 520495379
451366491 344173378
...

correct output
505241702 553085427

user output
500082364 504424633

Test 41

Verdict:

input
100
591414747 75940263
760367935 901888417
312356591 130275571
548496961 611293382
...

correct output
512794087 502710728

user output
509943219 509410150

Test 42

Verdict:

input
100
967034924 587586158
185430194 918715995
767527830 653946995
749180621 641621091
...

correct output
467598795 543711879

user output
501720771 501741201

Test 43

Verdict:

input
100
238363353 59249204
934941692 892631472
221963002 390559518
986350949 524427523
...

correct output
511067632 465512739

user output
498723140 498390572

Test 44

Verdict:

input
100
958701283 356460601
224848374 881788059
68992860 44771412
397401947 115595477
...

correct output
542243492 445601576

user output
517467787 506633836

Test 45

Verdict:

input
100
81935404 244103474
837431431 342493822
470738321 776814822
489180570 330726191
...

correct output
530569655 531085018

user output
513305103 512404323

Test 46

Verdict:

input
100
937837681 11934038
257096283 933290530
405355767 570001955
876668629 249890139
...

correct output
489890640 449453691

user output
503659852 501270119

Test 47

Verdict:

input
100
11139168 391337048
538883744 535937150
532332526 8099343
143698367 339543270
...

correct output
478577648 507747978

user output
499175750 501599422

Test 48

Verdict:

input
200
589284012 636562060
767928734 906523441
647212241 921212095
585063857 909729626
...

correct output
484364945 481613390

user output
501432960 499446772

Test 49

Verdict:

input
200
447773962 773442532
122816 137572579
324627123 157577940
253498609 99147813
...

correct output
528519875 485907028

user output
499049229 499895163

Test 50

Verdict:

input
200
468145963 198730372
27838076 590195590
467423861 520495379
451366491 344173378
...

correct output
482800416 512251704

user output
499732756 501331890

Test 51

Verdict:

input
200
591414747 75940263
760367935 901888417
312356591 130275571
548496961 611293382
...

correct output
492010316 481926957

user output
510895168 509410150

Test 52

Verdict:

input
200
967034924 587586158
185430194 918715995
767527830 653946995
749180621 641621091
...

correct output
473998199 537312475

user output
501055989 501076419

Test 53

Verdict:

input
200
238363353 59249204
934941692 892631472
221963002 390559518
986350949 524427523
...

correct output
535342378 489787485

user output
498723140 498390582

Test 54

Verdict:

input
200
958701283 356460601
224848374 881788059
68992860 44771412
397401947 115595477
...

correct output
541418009 466378372

user output
503659012 495619432

Test 55

Verdict:

input
200
81935404 244103474
837431431 342493822
470738321 776814822
489180570 330726191
...

correct output
471167122 531480104

user output
500933137 500032357

Test 56

Verdict:

input
200
937837681 11934038
257096283 933290530
405355767 570001955
876668629 249890139
...

correct output
480355638 503030740

user output
501435497 502178659

Test 57

Verdict:

input
200
11139168 391337048
538883744 535937150
532332526 8099343
143698367 339543270
...

correct output
488427758 499286474

user output
497603455 499332632

Test 58

Verdict:

input
1000
589284012 636562060
767928734 906523441
647212241 921212095
585063857 909729626
...

correct output
497956378 486069415

user output
499770346 499897650

Test 59

Verdict:

input
1000
447773962 773442532
122816 137572579
324627123 157577940
253498609 99147813
...

correct output
494047134 512602597

user output
499947585 499895173

Test 60

Verdict:

input
1000
468145963 198730372
27838076 590195590
467423861 520495379
451366491 344173378
...

correct output
497994845 501561827

user output
499400312 499428947

Test 61

Verdict:

input
1000
591414747 75940263
760367935 901888417
312356591 130275571
548496961 611293382
...

correct output
483630640 485770068

user output
499835929 499428837

Test 62

Verdict:

input
1000
967034924 587586158
185430194 918715995
767527830 653946995
749180621 641621091
...

correct output
484246063 524460613

user output
500572481 500319295

Test 63

Verdict:

input
1000
238363353 59249204
934941692 892631472
221963002 390559518
986350949 524427523
...

correct output
482084242 498558858

user output
500116484 499874901

Test 64

Verdict:

input
1000
958701283 356460601
224848374 881788059
68992860 44771412
397401947 115595477
...

correct output
517911118 490640905

user output
500835766 500617691

Test 65

Verdict:

input
1000
81935404 244103474
837431431 342493822
470738321 776814822
489180570 330726191
...

correct output
516584474 493117116

user output
499940933 499805983

Test 66

Verdict:

input
1000
937837681 11934038
257096283 933290530
405355767 570001955
876668629 249890139
...

correct output
505395058 493501350

user output
500650844 500910512

Test 67

Verdict:

input
1000
11139168 391337048
538883744 535937150
532332526 8099343
143698367 339543270
...

correct output
487882612 490398120

user output
499335434 499831600

Test 68

Verdict:

input
100000
589284012 636562060
767928734 906523441
647212241 921212095
585063857 909729626
...

correct output
499279419 501141977

user output
499998629 500001092

Test 69

Verdict:

input
100000
447773962 773442532
122816 137572579
324627123 157577940
253498609 99147813
...

correct output
499924856 502172257

user output
500005248 500013263

Test 70

Verdict:

input
100000
468145963 198730372
27838076 590195590
467423861 520495379
451366491 344173378
...

correct output
501207411 500741195

user output
500000896 500001372

Test 71

Verdict:

input
100000
591414747 75940263
760367935 901888417
312356591 130275571
548496961 611293382
...

correct output
500378568 501125669

user output
499999724 500001898

Test 72

Verdict:

input
100000
967034924 587586158
185430194 918715995
767527830 653946995
749180621 641621091
...

correct output
501286586 498468528

user output
500000154 499996265

Test 73

Verdict:

input
100000
238363353 59249204
934941692 892631472
221963002 390559518
986350949 524427523
...

correct output
500851969 501496653

user output
499999978 499997248

Test 74

Verdict:

input
100000
958701283 356460601
224848374 881788059
68992860 44771412
397401947 115595477
...

correct output
501129059 499760141

user output
500013817 500008547

Test 75

Verdict:

input
100000
81935404 244103474
837431431 342493822
470738321 776814822
489180570 330726191
...

correct output
501369501 501175764

user output
499997255 500002205

Test 76

Verdict:

input
100000
937837681 11934038
257096283 933290530
405355767 570001955
876668629 249890139
...

correct output
499822684 498958448

user output
499996416 499997767

Test 77

Verdict:

input
100000
11139168 391337048
538883744 535937150
532332526 8099343
143698367 339543270
...

correct output
500231553 501043880

user output
500000496 500001986