Submission #846258


Source Code Expand

Copy
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MX = 2155;
const int MAXN = 1 << 18;
const int MOD = 1; // 1000 * 1000 * 1000 + 7;
const int INF = 2e9;
const double PI = acos(-1.0);

bool isPrime(int x) {
	for (int i = 2; i * i <= x; i++) if (x % i == 0) return 0;
	return 1;
}

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

	vector<int> pr;
	for (int i = 2; i <= MX; i++) if (isPrime(i)) pr.push_back(i);

	int n;
	while (cin >> n) {
		vector<ll> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}

		int ans = 0;
		vector<vector<pair<int, int> > > mem(n);
		map<vector<pair<int, int> >, int> mp;
		set<vector<pair<int, int> > > used;
		for (int i = 0; i < n; i++) {
			int y = (int)pow(a[i], 1.0 / 3.0);
			while (1LL * y * y * y < a[i]) y++;
			while (1LL * y * y * y > a[i]) y--;
			if (1LL * y * y * y == a[i]) {
				if (ans == 0) ans++;
				continue;
			}

			ll x = a[i];
			vector<pair<int, int> > cur;
			for (int j = 0; j < (int)pr.size(); j++) {
				if (x % pr[j] == 0) {
					int cnt = 0;
					while (x % pr[j] == 0) {
						x /= pr[j];
						cnt++;
					}
					if (cnt % 3 != 0) cur.push_back(make_pair(pr[j], cnt % 3));
				}
			}
			if (x != 1) cur.push_back(make_pair(MX + 10 + i, 1));
			assert(!cur.empty());
			mem[i] = cur;
			mp[cur]++;
		}
		
		for (int i = 0; i < n; i++) {
			if (mem[i].empty()) continue;
			vector<pair<int, int> > cur = mem[i];
			if (used.find(cur) != used.end()) continue;
			vector<pair<int, int> > oth = cur;
			for (int j = 0; j < (int)oth.size(); j++) {
				oth[j].second = 3 - oth[j].second;
			}
			ans += max(mp[cur], mp[oth]);
			used.insert(cur);
			used.insert(oth);
		}
		cout << ans << endl;
	}

	return 0;
}

Submission Info

Submission Time
Task D - Anticube
User izban
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2134 Byte
Status WA
Exec Time 1506 ms
Memory 50688 KB

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 1481 ms 50688 KB
02.txt AC 1465 ms 50304 KB
03.txt AC 1499 ms 50304 KB
04.txt AC 1496 ms 50432 KB
05.txt AC 1459 ms 50304 KB
06.txt AC 1475 ms 50304 KB
07.txt AC 1486 ms 50304 KB
08.txt AC 1459 ms 50304 KB
09.txt AC 1506 ms 50304 KB
10.txt AC 1470 ms 50304 KB
11.txt AC 1031 ms 47104 KB
12.txt AC 1023 ms 47104 KB
13.txt WA 978 ms 46848 KB
14.txt WA 986 ms 46848 KB
15.txt WA 986 ms 46848 KB
16.txt WA 975 ms 46848 KB
17.txt AC 781 ms 6656 KB
18.txt AC 780 ms 6656 KB
19.txt AC 778 ms 6656 KB
20.txt AC 779 ms 6656 KB
21.txt WA 1063 ms 37760 KB
22.txt WA 1068 ms 37760 KB
23.txt WA 1076 ms 37760 KB
24.txt WA 1065 ms 37760 KB
25.txt WA 1064 ms 37760 KB
26.txt WA 1063 ms 37760 KB
27.txt AC 1259 ms 41984 KB
28.txt AC 43 ms 3328 KB
29.txt AC 50 ms 3328 KB
30.txt AC 678 ms 6528 KB
31.txt AC 681 ms 6528 KB
32.txt AC 679 ms 6528 KB
33.txt AC 4 ms 256 KB
34.txt AC 786 ms 6528 KB
35.txt AC 97 ms 3328 KB
36.txt AC 4 ms 256 KB
37.txt WA 1008 ms 45568 KB
38.txt WA 1011 ms 45568 KB
39.txt WA 1009 ms 45568 KB
40.txt WA 1010 ms 45568 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 4 ms 256 KB
s1.txt AC 4 ms 256 KB
s2.txt AC 4 ms 256 KB
s3.txt AC 4 ms 256 KB