結果
| 問題 |
No.1318 ABCD quadruplets
|
| コンテスト | |
| ユーザー |
carrot46
|
| 提出日時 | 2020-12-15 19:59:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 381 ms / 2,000 ms |
| コード長 | 2,076 bytes |
| コンパイル時間 | 1,887 ms |
| コンパイル使用メモリ | 174,928 KB |
| 実行使用メモリ | 13,312 KB |
| 最終ジャッジ日時 | 2024-09-20 02:04:57 |
| 合計ジャッジ時間 | 7,571 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#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;
}
carrot46