結果
問題 | No.2510 Six Cube Sum Counting |
ユーザー |
![]() |
提出日時 | 2023-10-21 00:13:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 786 ms / 4,000 ms |
コード長 | 1,488 bytes |
コンパイル時間 | 1,653 ms |
コンパイル使用メモリ | 140,028 KB |
最終ジャッジ日時 | 2025-02-17 11:39:38 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#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;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() && 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();}