結果

問題 No.3012 岩井星人グラフ
ユーザー wingu
提出日時 2025-01-25 13:16:31
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 323 ms / 2,000 ms
コード長 1,332 bytes
コンパイル時間 3,292 ms
コンパイル使用メモリ 282,508 KB
実行使用メモリ 5,968 KB
最終ジャッジ日時 2025-01-25 22:41:39
合計ジャッジ時間 10,609 ms
ジャッジサーバーID
(参考情報)
judge6 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef local
#include <debug.hpp>
#else
#define debug(...)
#endif
#define rep(i, n) for (int i = 0; i < n; i++)
template <class T> istream& operator>>(istream& I, vector<T>& V) {for (T& X : V) I >> X; return I;}
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
vector<int> di = {-1, 1, 0, 0}, dj = {0, 0, -1, 1}; int inf = 2e9; long INF = 1e18;

int main() {
    int x, y;
    cin >> x >> y;

    int n = 2 * x + x * (y - 2);
    vector<pair<int, int>> es;
    rep(i, x) {
        es.emplace_back(i, (i + 1) % x);
    }
    int idx = x, b = n - x;
    rep(i, x) {
        rep(j, y - 2) {
            if (j == 0) {
                es.emplace_back(i, idx++);
            } else {
                es.emplace_back(idx - 2, idx++);
            }
            if (j == y - 3) {
                es.emplace_back(idx - 1, b++);
            }
        }
        if (i == 0) debug(es);
    }
    vector<int> d(n);
    for (auto [u, v] : es) {
        d[u]++;
        d[v]++;
    }
    rep(i, n) debug(d[i]);
    cout << n << " " << (int)es.size() << endl;
    for (auto [u, v] : es) {
        cout << u + 1 << " " << v + 1 << endl;
    }
    return 0;
}
0