結果

問題 No.1318 ABCD quadruplets
ユーザー carrot46carrot46
提出日時 2020-12-15 19:17:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,056 bytes
コンパイル時間 1,742 ms
コンパイル使用メモリ 175,696 KB
実行使用メモリ 13,244 KB
最終ジャッジ日時 2023-10-20 06:21:28
合計ジャッジ時間 8,305 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
12,188 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 8 ms
12,188 KB
testcase_06 AC 8 ms
12,188 KB
testcase_07 AC 9 ms
12,188 KB
testcase_08 AC 9 ms
12,188 KB
testcase_09 WA -
testcase_10 AC 8 ms
12,188 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 366 ms
13,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <chrono>
#pragma GCC optimize("O3")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

//ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
const ll INF = (1LL<<60);

template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}
template<class T> void my_printv(std::vector<T> v,bool endline = true){
    if(!v.empty()){
        for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" ";
        std::cout<<v.back();
    }
    if(endline) std::cout<<std::endl;
}


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin>>N>>M;
    vec res(N + 1, 0);
    int sum, plus, id, max_a = 0, N2 = N * 2;
    while(max_a <= M || (max_a * 4LL) * (max_a * 4LL) + 4LL * max_a * max_a <= N2) ++max_a;
    vector<vector<bitset<401> > > ok(401, vector<bitset<401> >(401, bitset<401>(0)));
    rep(a, max_a) reps(b, a, M + 1) reps(c, b, M + 1) {
        int sum = (a + b + c + c);
        ok[a][b][c] = sum * sum + a*a + b*b + c*c + c*c <= N2;
    }
    rep(a, max_a){
        reps(b, a, M+1){
            if(!ok[a][b][b]) break;
            reps(c, b, M + 1){
                if(!ok[a][b][c]) break;
                sum = a + b + c;
                res[((sum + c) * (sum + c) + a * a + b * b + c * c * 2)>>1] += (a==b ? (b==c ? 1 : 6) : (b==c ? 4 : 12));
                plus = (a==b ? (b==c ? 4 : 12) : (b==c ? 12 : 24));
                for(int d2 = c * 2 + 2, id = (sum * sum + (sum + c + 1) * (c + 1) * 2 + a * a + b * b + c * c)>>1; id <= N; id += sum + d2 + 1, d2 += 2){
                    res[id] += plus;
                }
            }
        }
    }
    rep(i, N + 1) cout<<res[i]<<endl;
}
0