結果

問題 No.3075 Mex Recurrence Formula
ユーザー Zhiyuan Chen
提出日時 2025-03-28 21:28:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,556 bytes
コンパイル時間 2,514 ms
コンパイル使用メモリ 201,772 KB
実行使用メモリ 9,504 KB
最終ジャッジ日時 2025-03-28 21:28:59
合計ジャッジ時間 16,127 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int total = 2 * N;
    vector<pair<int, int>> pts(total);
    long long cx = 0, cy = 0;
    for (int i = 0; i < total; i++){
        int x, y; cin >> x >> y;
        pts[i] = {x, y};
        cx += x;
        cy += y;
    }
    cx /= total;
    cy /= total;
    vector<pair<int,int>> cand = {
        {1,0}, {0,1}, {1,1}, {1,-1},
        {1,2}, {2,1}, {1,-2}, {2,-1},
        {1,3}, {3,1}, {1,-3}, {3,-1},
        {2,3}, {3,2}, {2,-3}, {3,-2},
        {1,4}, {4,1}, {1,-4}, {4,-1}
    };
    for(auto &cb : cand){
        int a = cb.first, b = cb.second;
        vector<long long> vals(total);
        for (int i = 0; i < total; i++){
            vals[i] = (long long)a * pts[i].first + (long long)b * pts[i].second;
        }
        sort(vals.begin(), vals.end());
        if (vals[N] - vals[N - 1] >= 2) {
            long long c = - (vals[N - 1] + 1);
            cout << a << " " << b << " " << c;
            return 0;
        }
    }
    for(auto &cb : cand){
        int a = cx + cb.first, b = cy + cb.second;
        vector<long long> vals(total);
        for (int i = 0; i < total; i++){
            vals[i] = (long long)a * pts[i].first + (long long)b * pts[i].second;
        }
        sort(vals.begin(), vals.end());
        if (vals[N] - vals[N - 1] >= 2) {
            long long c = - (vals[N - 1] + 1);
            cout << a << " " << b << " " << c;
            return 0;
        }
    }
    return 0;
}
0