結果

問題 No.1318 ABCD quadruplets
ユーザー carrot46carrot46
提出日時 2020-12-15 19:59:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 388 ms / 2,000 ms
コード長 2,076 bytes
コンパイル時間 1,777 ms
コンパイル使用メモリ 175,608 KB
実行使用メモリ 13,244 KB
最終ジャッジ日時 2023-10-20 06:27:47
合計ジャッジ時間 7,845 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
12,188 KB
testcase_01 AC 9 ms
12,188 KB
testcase_02 AC 9 ms
12,188 KB
testcase_03 AC 9 ms
12,188 KB
testcase_04 AC 9 ms
12,188 KB
testcase_05 AC 9 ms
12,188 KB
testcase_06 AC 9 ms
12,188 KB
testcase_07 AC 9 ms
12,188 KB
testcase_08 AC 9 ms
12,188 KB
testcase_09 AC 9 ms
12,188 KB
testcase_10 AC 9 ms
12,188 KB
testcase_11 AC 9 ms
12,188 KB
testcase_12 AC 9 ms
12,188 KB
testcase_13 AC 31 ms
12,188 KB
testcase_14 AC 230 ms
13,244 KB
testcase_15 AC 31 ms
12,188 KB
testcase_16 AC 227 ms
12,980 KB
testcase_17 AC 143 ms
12,980 KB
testcase_18 AC 209 ms
12,980 KB
testcase_19 AC 199 ms
13,244 KB
testcase_20 AC 29 ms
12,188 KB
testcase_21 AC 59 ms
12,452 KB
testcase_22 AC 204 ms
13,244 KB
testcase_23 AC 378 ms
13,244 KB
testcase_24 AC 365 ms
13,244 KB
testcase_25 AC 231 ms
13,244 KB
testcase_26 AC 218 ms
13,244 KB
testcase_27 AC 312 ms
13,244 KB
testcase_28 AC 236 ms
13,244 KB
testcase_29 AC 245 ms
13,244 KB
testcase_30 AC 385 ms
13,244 KB
testcase_31 AC 239 ms
13,244 KB
testcase_32 AC 388 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, max_a = 0, N2 = N * 2, M2 = M * 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 && d2 <= M2; id += sum + d2 + 1, d2 += 2){
                    res[id] += plus;
                }
            }
        }
    }
    rep(i, N + 1) cout<<res[i]<<endl;
}
0