結果

問題 No.2510 Six Cube Sum Counting
ユーザー ゆにぽけゆにぽけ
提出日時 2023-10-21 00:08:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,570 bytes
コンパイル時間 1,817 ms
コンパイル使用メモリ 146,588 KB
実行使用メモリ 149,356 KB
最終ジャッジ日時 2023-10-21 00:09:06
合計ジャッジ時間 23,141 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 596 ms
147,192 KB
testcase_01 AC 627 ms
147,188 KB
testcase_02 AC 702 ms
148,300 KB
testcase_03 AC 630 ms
147,192 KB
testcase_04 AC 591 ms
147,188 KB
testcase_05 AC 616 ms
147,188 KB
testcase_06 AC 604 ms
147,188 KB
testcase_07 AC 627 ms
147,188 KB
testcase_08 AC 601 ms
147,188 KB
testcase_09 AC 626 ms
147,188 KB
testcase_10 AC 602 ms
147,188 KB
testcase_11 AC 626 ms
147,188 KB
testcase_12 AC 602 ms
147,188 KB
testcase_13 AC 628 ms
147,188 KB
testcase_14 AC 601 ms
147,188 KB
testcase_15 AC 621 ms
147,188 KB
testcase_16 AC 598 ms
147,188 KB
testcase_17 AC 620 ms
147,188 KB
testcase_18 AC 602 ms
147,188 KB
testcase_19 AC 628 ms
147,188 KB
testcase_20 WA -
testcase_21 AC 700 ms
148,300 KB
testcase_22 AC 772 ms
149,356 KB
testcase_23 AC 682 ms
148,564 KB
testcase_24 AC 762 ms
148,300 KB
testcase_25 AC 604 ms
147,188 KB
testcase_26 AC 635 ms
147,188 KB
testcase_27 AC 646 ms
147,772 KB
testcase_28 AC 634 ms
147,188 KB
testcase_29 AC 703 ms
148,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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();
}
0