Submission #847442


Source Code Expand

Copy
#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;
using ll=long long;

const int limit=3000;
bool isprime[limit+1];
vector<ll> prime;

void init(){
	rep(i,limit+1) isprime[i]=true;
	isprime[0]=isprime[1]=false;
	for(ll i=2;i*i<=limit;++i){
		if(isprime[i]){
			prime.push_back(i);
			for(ll j=i*i;j<=limit;j+=i)
				isprime[j]=false;
		}
	}
	return;
}

map<ll,int> cnt;

int main(void){
	init();
	const int m=prime.size();

	int n;
	cin >> n;
	rep(i,n){
		ll cur;
		cin >> cur;

		rep(j,m){
			ll cube=1LL*prime[j]*prime[j]*prime[j];
			while(cur%cube==0) cur/=cube;
		}
		cnt[cur]++;
	}

	ll ans=0LL;

	/*
	for(auto &it:cnt){
		cout << it.first << " " << it.second << " " << comp[it.first] << endl;
	}
	*/

	for(auto &it:cnt){
		if(it.first==1)
			ans+=min<ll>(1LL,it.second);
		else{
			ll tar=1LL*it.first*it.first;
			rep(j,m){
				ll cube=1LL*prime[j]*prime[j]*prime[j];
				while(tar%cube==0) tar/=cube;
			}
			ans+=max<ll>(it.second,cnt[tar]);
			it.second=0LL;
			cnt[tar]=0LL;
		}
	}
	cout << ans << endl;
	return 0;	
}

Submission Info

Submission Time
Task D - Anticube
User Hec
Language C++14 (GCC 5.4.1)
Score 1100
Code Size 1902 Byte
Status AC
Exec Time 454 ms
Memory 21376 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1100 / 1100
Status
AC × 3
AC × 51
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 431 ms 18688 KB
02.txt AC 435 ms 18688 KB
03.txt AC 449 ms 18688 KB
04.txt AC 432 ms 18688 KB
05.txt AC 435 ms 18688 KB
06.txt AC 433 ms 18688 KB
07.txt AC 454 ms 18688 KB
08.txt AC 446 ms 18688 KB
09.txt AC 432 ms 18688 KB
10.txt AC 432 ms 18688 KB
11.txt AC 256 ms 5760 KB
12.txt AC 248 ms 5760 KB
13.txt AC 261 ms 7552 KB
14.txt AC 248 ms 7552 KB
15.txt AC 257 ms 7552 KB
16.txt AC 262 ms 7552 KB
17.txt AC 160 ms 384 KB
18.txt AC 164 ms 256 KB
19.txt AC 166 ms 256 KB
20.txt AC 157 ms 256 KB
21.txt AC 326 ms 12032 KB
22.txt AC 315 ms 12032 KB
23.txt AC 326 ms 12032 KB
24.txt AC 329 ms 12032 KB
25.txt AC 330 ms 11904 KB
26.txt AC 322 ms 11904 KB
27.txt AC 447 ms 21376 KB
28.txt AC 64 ms 256 KB
29.txt AC 65 ms 256 KB
30.txt AC 75 ms 256 KB
31.txt AC 78 ms 256 KB
32.txt AC 77 ms 256 KB
33.txt AC 4 ms 256 KB
34.txt AC 175 ms 256 KB
35.txt AC 177 ms 256 KB
36.txt AC 4 ms 256 KB
37.txt AC 267 ms 7296 KB
38.txt AC 268 ms 7424 KB
39.txt AC 270 ms 7296 KB
40.txt AC 269 ms 7424 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