Submission #846472


Source Code Expand

Copy
/*
*/
#define _CRT_SECURE_NO_WARNINGS

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>  
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <ctime>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define eps 1e-10
#define M_PI 3.141592653589793
#define bs 1000000007;
#define bsize 512

const int N = 233031;

using namespace std;

int n;
int pr[N];
vector<int> primes;

map<vector<pair<long long, long long> >, int> have;
map<vector<pair<long long, long long> >, int>::iterator it;
long long ans;

vector<pair<long long, long long> > paired(vector<pair<long long, long long> > v)
{
	vector<pair<long long, long long> > res;

	for (int i = 0; i < v.size(); i++)
	{
		if (v[i].second == -1)
		{
			res.push_back(make_pair(-1, -1));
			return res;
		}
	}
	
	for (int i = 0; i < v.size(); i++)
	{
		res.push_back(v[i]);
		res[i].second = 3 - res[i].second;
		res[i].second %= 3;
	}

}

bool perf_square(long long x)
{
	long long val = sqrt(x + .5);
	return (val*val == x);
}

vector<pair<long long, long long> > parse(long long x)
{
	vector<pair<long long, long long> > res;

	for (int i = 0; i < primes.size(); i++)
	{
		if (x%primes[i])
			continue;
		int cnt = 0;
		while (x%primes[i] == 0)
		{
			cnt++;
			x /= primes[i];
		}
		if (cnt % 3 == 0)
			continue;
		res.push_back(make_pair(primes[i], cnt % 3));
	}
	if (x == 1)
		return res;
	if (perf_square(x))
	{
		int ss = sqrt(x + .5);
		res.push_back(make_pair(ss, 2));
		return res;
	}
	res.push_back(make_pair(1, -1));
	return res;
}
int main(){
	//freopen("beavers.in","r",stdin);
	//freopen("beavers.out","w",stdout);
	//freopen("F:/in.txt","r",stdin);
	//freopen("F:/output.txt","w",stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n;

	pr[1] = 1;
	for (int i = 2; i <= 10000; i++)
	{
		if (pr[i] == 0)
		{
			for (int j = i * 2; j <= 10000; j+=i)
			{
				pr[j] = 1;
			}
		}
	}

	for (int i = 2; i <= 3000; i++)
	{
		if (pr[i] == 0)
		{
			primes.push_back(i);
		}
	}

	for (int i = 1; i <= n; i++)
	{
		long long val;
		cin >> val;
		vector<pair<long long, long long> > p = parse(val);
		/*for (int j = 0; j < p.size(); j++)
		{
			cout << p[j].first << "%" << p[j].second << endl;
		}
		cout << "!" << endl;
		*/
		have[p]++;
	}

	for (it = have.begin(); it != have.end(); it++)
	{
		int cnt = (*it).second;
		vector<pair<long long, long long> > p = (*it).first;
		vector<pair<long long, long long> > p2 = paired(p);
		if (p2 == p)
		{
			ans += 2;
			continue;
		}
		if (have.find(p2) == have.end())
		{
			ans += cnt * 2;
			continue;
		}
		ans += max(have[p2], have[p]);
	}

	cout << ans / 2 << endl;

	cin.get(); cin.get();
	return 0;
}

Submission Info

Submission Time
Task D - Anticube
User LeBron
Language C++14 (GCC 5.4.1)
Score 0
Code Size 3141 Byte
Status WA
Exec Time 929 ms
Memory 7808 KB

Compile Error

./Main.cpp:32:0: warning: "M_PI" redefined
 #define M_PI 3.141592653589793
 ^
In file included from /usr/include/c++/5/cmath:44:0,
                 from /usr/include/c++/5/complex:44,
                 from ./Main.cpp:9:
/usr/include/math.h:372:0: note: this is the location of the previous definition
 # define M_PI  3.14159265358979323846 /* pi */
 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
AC × 3
AC × 37
WA × 14
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 905 ms 6144 KB
02.txt AC 905 ms 6144 KB
03.txt AC 900 ms 6144 KB
04.txt AC 901 ms 6144 KB
05.txt AC 899 ms 6144 KB
06.txt AC 903 ms 6144 KB
07.txt AC 903 ms 6144 KB
08.txt AC 903 ms 6016 KB
09.txt AC 906 ms 6016 KB
10.txt AC 900 ms 6144 KB
11.txt AC 785 ms 256 KB
12.txt AC 784 ms 256 KB
13.txt WA 799 ms 1152 KB
14.txt WA 800 ms 1152 KB
15.txt WA 801 ms 1152 KB
16.txt WA 813 ms 1152 KB
17.txt AC 878 ms 384 KB
18.txt AC 879 ms 384 KB
19.txt AC 891 ms 256 KB
20.txt AC 878 ms 384 KB
21.txt WA 854 ms 2304 KB
22.txt WA 854 ms 2304 KB
23.txt WA 852 ms 2432 KB
24.txt WA 852 ms 2432 KB
25.txt WA 852 ms 2304 KB
26.txt WA 855 ms 2432 KB
27.txt AC 929 ms 7808 KB
28.txt AC 781 ms 256 KB
29.txt AC 788 ms 256 KB
30.txt AC 802 ms 256 KB
31.txt AC 803 ms 256 KB
32.txt AC 804 ms 256 KB
33.txt AC 4 ms 256 KB
34.txt AC 871 ms 256 KB
35.txt AC 848 ms 256 KB
36.txt AC 4 ms 256 KB
37.txt WA 802 ms 768 KB
38.txt WA 800 ms 896 KB
39.txt WA 802 ms 768 KB
40.txt WA 801 ms 768 KB
41.txt AC 4 ms 256 KB
42.txt AC 4 ms 256 KB
43.txt AC 4 ms 256 KB
44.txt AC 4 ms 256 KB
45.txt AC 4 ms 256 KB
46.txt AC 4 ms 256 KB
47.txt AC 4 ms 256 KB
48.txt AC 5 ms 256 KB
s1.txt AC 4 ms 256 KB
s2.txt AC 4 ms 256 KB
s3.txt AC 4 ms 256 KB