結果
| 問題 |
No.2510 Six Cube Sum Counting
|
| コンテスト | |
| ユーザー |
ゆにぽけ
|
| 提出日時 | 2023-10-21 00:08:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,570 bytes |
| コンパイル時間 | 1,776 ms |
| コンパイル使用メモリ | 140,668 KB |
| 最終ジャッジ日時 | 2025-02-17 11:37:34 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 WA * 1 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cmath>
#include<ctime>
#include<iomanip>
#include<numeric>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<random>
using namespace std;
const int N = 300;
vector<int> V[N+1];
void solve()
{
int X;cin >> X;
vector<pair<int,pair<int,pair<int,int>>>> A;
for(int i = 0;i <= N;i++)for(int j = i;j <= N;j++)for(int k = j;k <= N;k++) A.push_back(make_pair(i*i*i+j*j*j+k*k*k,make_pair(i,make_pair(j,k))));
sort(A.begin(),A.end());
vector<pair<int,pair<int,pair<int,int>>>> B(A.rbegin(),A.rend());
long long ans = 0;
int bi = 0;
unordered_set<long long> S;
for(int i = 0;i < (int)A.size();i++)
{
while(bi < (int)B.size() && A[i].first+B[bi].first > X) bi++;
if(bi == (int)B.size() || B[bi].first < A[i].first) break;
if(bi < (int)B.size() && A[i].first+B[bi].first == X)
{
vector<int> v;
v.push_back(A[i].second.first);
v.push_back(A[i].second.second.first);
v.push_back(A[i].second.second.second);
v.push_back(B[bi].second.first);
v.push_back(B[bi].second.second.first);
v.push_back(B[bi].second.second.second);
sort(v.begin(),v.end());
long long val = 0;
for(int j = 0;j < 6;j++) val = val*(N+1) + v[j];
if(S.count(val));
else ans++,S.insert(val);
//cout << A[i] << " " << B[bi] << endl;
}
}
cout << ans << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt = 1;
//cin >> tt;
while(tt--) solve();
}
ゆにぽけ