結果

問題 No.1880 Many Ways
ユーザー gazellegazelle
提出日時 2022-03-18 21:43:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,596 bytes
コンパイル時間 2,332 ms
コンパイル使用メモリ 201,292 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 09:29:11
合計ジャッジ時間 17,337 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i, n, m) for (long long i = (n); i < (long long)(m); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll inf = 1000000000;
constexpr ll mod = 998244353;
constexpr ld eps = 1e-6;

template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
    os << to_string(p.first) << " " << to_string(p.second);
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
    REP(i, v.size()) {
        if (i) os << " ";
        os << v[i];
    }
    return os;
}

constexpr int K = 40;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a;
    cin >> a;

    int N = 3 * K + 1;
    vector<pair<int, int>> edges;

    for (int i = 0; i < K; i++) {
        if (i != K - 1) {
            edges.pb({3 * i, 3 * (i + 1)});
            edges.pb({3 * i + 1, 3 * (i + 1) + 1});
            edges.pb({3 * i + 1, 3 * (i + 1) + 2});
            edges.pb({3 * i + 2, 3 * (i + 1) + 2});
            edges.pb({3 * i + 2, 3 * (i + 1) + 1});
        } else {
            edges.pb({3 * i + 1, N - 1});
            edges.pb({3 * i + 2, N - 1});
        }

        if (a & (1LL << (K - 1 - i))) {
            edges.pb({3 * i, 3 * i + 1});
        }
    }

    for (auto &edge : edges) {
        edge.first++;
        edge.second++;
    }

    int M = (int)edges.size();

    cout << N << " " << M << endl;
    for (auto edge : edges) cout << edge << endl;

    return 0;
}
0