Submission #69135852


Source Code Expand

#ifdef LOCAL
#include "snippets/debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42
#endif

#define i64 long long

template<typename T>
inline T Gcd(T a, T b) {
    a = abs(a), b = abs(b);
    if (b > a) swap(a, b);
    assert(b >= 0);
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

#define int i64

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt = 1;
    #ifdef LOCAL
    // cin >> tt;
    #endif
    for (int tc = 1; tc <= tt; tc++) {
        debug(tc);
        int n;
        cin >> n;
        int seed = 983275;
        mt19937 gen(seed); 
        vector<pair<int, int>> pts(n);
        for (auto &[x, y] : pts) cin >> x >> y;
        shuffle(pts.begin(), pts.end(), gen);
        debug(pts);
        set<tuple<i64, i64, i64>> st;
        tuple<i64, i64, i64> ans;
        int done = false;
        function Good = [&] (i64 a, i64 b, i64 c) {
            int cnt = 0;
            for (int i = 0; i < n && cnt <= n / 2; i++) {
                auto [x, y] = pts[i];
                debug(a * x + b * y + c, x, y);
                if (a * x + b * y + c == 0) {
                    cnt++;
                }
            }
            debug(a, b, c, cnt);
            if (cnt > n / 2) done = true;
            return done;
        };
        function Abc = [&] (int i1, int i2) -> tuple<int, int, int> {
            auto [x1, y1] = pts[i1];
            auto [x2, y2] = pts[i2];
            i64 a = (y1 - y2), b = (-x1 + x2), c = -(y1 - y2) * x1 - (x2 - x1) * y1;
            int gc = Gcd(Gcd(a, b), c);
            return {a / gc, b / gc, c / gc};

        };
        debug();
        int cc = 0;
        for (int i = 0; i < n && cc < 1000 && !done; i += 2) {
            int i1 = i;
            int i2 = (i + 1) % n;
            auto [a, b, c] = Abc(i1, i2);
            if (st.contains({a, b, c})) continue;
            cc++;
            if (Good(a, b, c)) {
                ans = {a, b, c};
            }
            else {
                st.emplace(a, b, c);
                st.emplace(-a, -b, -c);
            }
        }
        debug(st);
        if (done) {
            cout << "Yes\n";
            auto [a, b, c] = ans;
            cout << a << ' ' << b << ' ' << c << '\n';
        }
        else {
            cout << "No\n";
        }
    }
    debug(verify);
}

Submission Info

Submission Time
Task E - Colinear
User anuragskadam
Language C++ 23 (gcc 12.2)
Score 450
Code Size 2460 Byte
Status AC
Exec Time 687 ms
Memory 11072 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:6:20: warning: statement has no effect [-Wunused-value]
    6 | #define debug(...) 42
      |                    ^~
Main.cpp:33:9: note: in expansion of macro ‘debug’
   33 |         debug(tc);
      |         ^~~~~
Main.cpp:6:20: warning: statement has no effect [-Wunused-value]
    6 | #define debug(...) 42
      |                    ^~
Main.cpp:41:9: note: in expansion of macro ‘debug’
   41 |         debug(pts);
      |         ^~~~~
Main.cpp: In lambda function:
Main.cpp:6:20: warning: statement has no effect [-Wunused-value]
    6 | #define debug(...) 42
      |                    ^~
Main.cpp:49:17: note: in expansion of macro ‘debug’
   49 |                 debug(a * x + b * y + c, x, y);
      |                 ^~~~~
Main.cpp:6:20: warning: statement has no effect [-Wunused-value]
    6 | #define debug(...) 42
      |                    ^~
Main.cpp:54:13: note: in expansion of macro ‘debug’
   54 |             debug(a, b, c, cnt);
      |             ^~~~~
Main.cpp: In function ‘int main()’:
Main.cpp:6:20: warning: statement has no effect [-Wunused-value]
    6 | #define debug(...) 42
      |                    ^~
Main.cpp:66:9: note: in expansion of macro ‘debug’
   66 |         debug();
      |         ^~~~~
Main.cpp:6:20: warning: statement has no effect [-Wunused-value]
    6 | #define debug(...) 42
      |                    ^~
Main.cpp:82:9: note: in expansion of macro ‘debug’
   82 |         debug(st);
      |         ^~~~~
Main.cpp:6:20: warning: statement has no effect [-Wunused-value]
    6 | #define debug(...) 42
      |                    ^~
Main.cpp:92:5: note: in expansion of macro ‘debug’
   92 |     debug(verify);
      |     ^~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 3
AC × 45
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 02_corner_1_00.txt, 02_corner_1_01.txt, 02_corner_1_02.txt, 02_corner_1_03.txt, 02_corner_1_04.txt, 02_corner_1_05.txt, 03_corner_2_00.txt, 03_corner_2_01.txt, 03_corner_2_02.txt, 03_corner_2_03.txt, 04_corner_3_00.txt, 04_corner_3_01.txt, 04_corner_3_02.txt, 04_corner_3_03.txt, 04_corner_3_04.txt, 04_corner_3_05.txt, 04_corner_3_06.txt, 04_corner_3_07.txt, 04_corner_3_08.txt, 04_corner_3_09.txt, 05_corner_4_00.txt, 05_corner_4_01.txt, 06_corner_5_00.txt, 06_corner_5_01.txt, 07_corner_6_00.txt, 07_corner_6_01.txt, 07_corner_6_02.txt, 07_corner_6_03.txt, 07_corner_6_04.txt, 07_corner_6_05.txt, 07_corner_6_06.txt, 07_corner_6_07.txt, 07_corner_6_08.txt, 07_corner_6_09.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3476 KiB
00_sample_01.txt AC 1 ms 3424 KiB
00_sample_02.txt AC 1 ms 3456 KiB
01_random_00.txt AC 51 ms 9224 KiB
01_random_01.txt AC 684 ms 11068 KiB
01_random_02.txt AC 64 ms 10960 KiB
01_random_03.txt AC 683 ms 11068 KiB
01_random_04.txt AC 66 ms 10968 KiB
01_random_05.txt AC 685 ms 11064 KiB
01_random_06.txt AC 687 ms 11004 KiB
01_random_07.txt AC 687 ms 10836 KiB
02_corner_1_00.txt AC 69 ms 10924 KiB
02_corner_1_01.txt AC 68 ms 10904 KiB
02_corner_1_02.txt AC 64 ms 10968 KiB
02_corner_1_03.txt AC 62 ms 10912 KiB
02_corner_1_04.txt AC 65 ms 11048 KiB
02_corner_1_05.txt AC 64 ms 10924 KiB
03_corner_2_00.txt AC 60 ms 11072 KiB
03_corner_2_01.txt AC 62 ms 10996 KiB
03_corner_2_02.txt AC 65 ms 10976 KiB
03_corner_2_03.txt AC 68 ms 10956 KiB
04_corner_3_00.txt AC 1 ms 3620 KiB
04_corner_3_01.txt AC 1 ms 3616 KiB
04_corner_3_02.txt AC 1 ms 3332 KiB
04_corner_3_03.txt AC 1 ms 3432 KiB
04_corner_3_04.txt AC 1 ms 3452 KiB
04_corner_3_05.txt AC 1 ms 3472 KiB
04_corner_3_06.txt AC 1 ms 3428 KiB
04_corner_3_07.txt AC 1 ms 3488 KiB
04_corner_3_08.txt AC 1 ms 3480 KiB
04_corner_3_09.txt AC 1 ms 3436 KiB
05_corner_4_00.txt AC 64 ms 10968 KiB
05_corner_4_01.txt AC 63 ms 10968 KiB
06_corner_5_00.txt AC 2 ms 3576 KiB
06_corner_5_01.txt AC 1 ms 3480 KiB
07_corner_6_00.txt AC 66 ms 10960 KiB
07_corner_6_01.txt AC 64 ms 10920 KiB
07_corner_6_02.txt AC 63 ms 11020 KiB
07_corner_6_03.txt AC 64 ms 10912 KiB
07_corner_6_04.txt AC 65 ms 11008 KiB
07_corner_6_05.txt AC 66 ms 10936 KiB
07_corner_6_06.txt AC 64 ms 11060 KiB
07_corner_6_07.txt AC 63 ms 10792 KiB
07_corner_6_08.txt AC 68 ms 10976 KiB
07_corner_6_09.txt AC 63 ms 10992 KiB