Submission #847131


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

vector<ll> Primes;
set<ll> m;
set<ll> m2;

P f(ll x){
	P ret = P(1,1);
	rep(i,Primes.size()){
		ll p = Primes[i];
		ll cnt = 0;
		while(x%p ==0){
			x /= p;
			cnt ++;
		}
		if(cnt%3 == 1){
			ret.fr *= p;
			ret.sc *= p*p;
		}
		else if(cnt%3 == 2){
			ret.fr *= p*p;
			ret.sc *= p;
		}
		if(ret.sc > 10000000000)return P(-1,-1);
	}
	if(m.find(x) != m.end()){
		ret.fr *= x;
		ret.sc *= (ll)(sqrt((ld)x)+0.5);
		x = 1;
	}
	else if(m2.find(x) != m2.end()){
		ret.fr *= x;
		ret.sc *= x;
		if(ret.sc > 10000000000)return P(-1,-1);
		ret.sc *= x;
		x = 1;
	}
	if(x != 1)return P(-1,-1);
	else return ret;
}

int main(){
	bool prime[100010];
	rep(i,100010)prime[i] = true;
	for(ll i = 2 ; i < 100010 ; i ++){
		if(prime[i]){
			if(i < 3000)Primes.pb(i);
			else {
				m.insert(i*i);
				m2.insert(i);
			}
			for(ll j = i*i ; j < 100010 ; j += i){
				prime[j] = false;
			}
		}
	}
	//cout << Primes.size() << endl;
	
	int n;
	ll s[100010];
	scanf("%d",&n);
	rep(i,n)scanf("%lld",&s[i]);
	
	map<ll,P> MAP;
	int cnt = 0;
	bool t = false;
	rep(i,n){
		P p = f(s[i]);
		if(p.fr == -1)cnt ++;
		else if(p.fr == 1)t = true;
		else {
			if(p.fr < p.sc)MAP[p.fr].fr ++;
			else MAP[p.sc].sc ++;
		}
	}
	
	if(t)cnt ++;
	for(map<ll,P>::iterator itr = MAP.begin() ; itr != MAP.end() ; itr++){
		cnt += max ( itr->sc.fr , itr->sc.sc );
	}
	cout << cnt << endl;
}

Submission Info

Submission Time
Task D - Anticube
User yokozuna57
Language C++14 (GCC 5.4.1)
Score 1100
Code Size 2437 Byte
Status AC
Exec Time 871 ms
Memory 7168 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:95:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
./Main.cpp:96:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  rep(i,n)scanf("%lld",&s[i]);
                             ^

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 753 ms 2048 KB
02.txt AC 749 ms 2048 KB
03.txt AC 750 ms 2048 KB
04.txt AC 760 ms 2048 KB
05.txt AC 760 ms 2048 KB
06.txt AC 754 ms 2048 KB
07.txt AC 753 ms 2048 KB
08.txt AC 759 ms 2048 KB
09.txt AC 748 ms 2048 KB
10.txt AC 754 ms 2048 KB
11.txt AC 822 ms 1920 KB
12.txt AC 807 ms 1920 KB
13.txt AC 801 ms 2560 KB
14.txt AC 813 ms 2560 KB
15.txt AC 821 ms 2560 KB
16.txt AC 825 ms 2560 KB
17.txt AC 847 ms 2048 KB
18.txt AC 856 ms 2048 KB
19.txt AC 851 ms 2048 KB
20.txt AC 855 ms 1920 KB
21.txt AC 822 ms 2304 KB
22.txt AC 825 ms 2304 KB
23.txt AC 806 ms 2304 KB
24.txt AC 823 ms 2304 KB
25.txt AC 816 ms 2304 KB
26.txt AC 840 ms 2304 KB
27.txt AC 846 ms 7168 KB
28.txt AC 776 ms 1920 KB
29.txt AC 774 ms 1920 KB
30.txt AC 783 ms 2048 KB
31.txt AC 778 ms 2048 KB
32.txt AC 797 ms 1920 KB
33.txt AC 10 ms 1152 KB
34.txt AC 847 ms 1920 KB
35.txt AC 843 ms 1920 KB
36.txt AC 11 ms 1152 KB
37.txt AC 831 ms 2048 KB
38.txt AC 827 ms 2048 KB
39.txt AC 871 ms 2048 KB
40.txt AC 817 ms 2048 KB
41.txt AC 10 ms 1152 KB
42.txt AC 10 ms 1152 KB
43.txt AC 11 ms 1152 KB
44.txt AC 10 ms 1152 KB
45.txt AC 11 ms 1152 KB
46.txt AC 10 ms 1152 KB
47.txt AC 10 ms 1152 KB
48.txt AC 11 ms 1152 KB
s1.txt AC 11 ms 1152 KB
s2.txt AC 11 ms 1152 KB
s3.txt AC 11 ms 1152 KB