結果

問題 No.1318 ABCD quadruplets
ユーザー t33ft33f
提出日時 2020-12-16 19:27:06
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 557 ms / 2,000 ms
コード長 1,095 bytes
コンパイル時間 885 ms
コンパイル使用メモリ 88,196 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-20 09:48:03
合計ジャッジ時間 6,521 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 10 ms
4,348 KB
testcase_14 AC 205 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 275 ms
4,348 KB
testcase_17 AC 15 ms
4,348 KB
testcase_18 AC 181 ms
4,348 KB
testcase_19 AC 70 ms
4,348 KB
testcase_20 AC 9 ms
4,352 KB
testcase_21 AC 31 ms
4,352 KB
testcase_22 AC 16 ms
4,352 KB
testcase_23 AC 551 ms
4,352 KB
testcase_24 AC 502 ms
4,352 KB
testcase_25 AC 103 ms
4,372 KB
testcase_26 AC 52 ms
4,372 KB
testcase_27 AC 365 ms
4,372 KB
testcase_28 AC 122 ms
4,372 KB
testcase_29 AC 155 ms
4,372 KB
testcase_30 AC 557 ms
4,372 KB
testcase_31 AC 112 ms
4,372 KB
testcase_32 AC 554 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <unordered_map>
#include <vector>
using namespace std;

int calc(int a, int b, int c, int d) {
    int s = d, r = 0;
    r += d * s;
    s += c;
    r += c * s;
    s += b;
    r += b * s;
    s += a;
    r += a * s;
    return r;
}

int calc_perm_count(int a, int b, int c, int d) {
    if (a == d) return 1;
    if (a == c || b == d) return 4;
    if (a == b && c == d) return 6;
    if (a == b || b == c || c == d) return 12;
    return 24;
}

vector<int> solve(int n, int m) {
    vector<int> ans(n+1, 0);
    for (int a = 0; a <= m; a++) {
        for (int b = a; b <= m; b++) {
            for (int c = b; c <= m; c++) {
                for (int d = c; d <= m; d++) {
                    if (int v = calc(a, b, c, d); v > n) break;
                    else ans[v] += calc_perm_count(a, b, c, d);
                }
            }
        }
    }
    return ans;
}

int main() {
    int n, m; cin >> n >> m;
    vector<int> ans = solve(n, m);
    for (int x : ans) printf("%d\n", x);
}
0