結果

問題 No.2597 Yet Another Topological Problem
ユーザー fdironia
提出日時 2023-12-25 08:15:19
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 1,088 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 91,708 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-27 14:13:14
合計ジャッジ時間 3,466 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 55
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <utility>
#include <vector>

using namespace std;

using pii = pair<int, int>;
using vp = vector<pii>;

int main() {
    int p, q;
    cin >> p >> q;

    if (p == 1) {
        cout << "Impossible" << endl;
        return 0;
    }

    cout << "Possible" << endl;

    int k = (2 * q / p) / 2;
    int x = 0, y = 0;
    vp ans(1, {x, y});
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < k - i; j++) {
            ans.emplace_back(x, --y);
        }

        for (int j = 0; j < k - i; j++) {
            ans.emplace_back(++x, y);
        }

        for (int j = 0; j < k - i; j++) {
            ans.emplace_back(x, ++y);
        }

        for (int j = 0; j < i + 1; j++) {
            ans.emplace_back(x, ++y);
        }

        for (int j = 0; j < i + 1; j++) {
            ans.emplace_back(++x, y);
        }

        for (int j = 0; j < i + 1; j++) {
            ans.emplace_back(x, --y);
        }
    }

    cout << (int)ans.size() - 1 << endl;
    for (auto [x, y] : ans) {
        cout << x << " " << y << endl;
    }

    return 0;
}
0