Contest Duration: - (local time) (110 minutes) Back to Home

Submission #846331

Source Code Expand

Copy
```#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
struct rpr{
in x,y;
rpr(in a=0, in b=0){
x=a;
y=b;
}
rpr sp()const{
return rpr(y,x);
}
bool operator<(const rpr cp)const{
if(x!=cp.x)
return x<cp.x;
return y<cp.y;
}
};
const in ulm=in(1e10)+9;
const in crt=2500;
in sm=0;
map<rpr,in> mp;
void pr(in n){
VI pm,pw;
for(in i=2;i<=crt && i<=n;++i){
if(n%i)
continue;
pm.PB(i);
pw.PB(0);
while(n%i==0){
n/=i;
++pw.back();
}
pw.back()%=3;
}
if(n!=1 && n<crt*crt){
pm.PB(n);
pw.PB(1);
n=1;
}
if(n>=crt*crt){
in mn=crt-1;
in mx=1e6;
in md;
while(mx-mn>1){
md=(mx+mn)/2;
if(md*md<=n)
mn=md;
else
mx=md;
}
if(mn*mn!=n){
++sm;
return;
}
pm.PB(mn);
pw.PB(2);
n=1;
}
in tx=1;
in ty=1;
forv(i,pm){
forn(j,pw[i])
tx*=pm[i];
forn(j,(3-pw[i])%3){
ty*=pm[i];
if(ty>ulm){
++sm;
return;
}
}
}
++mp[rpr(tx,ty)];
mp[rpr(ty,tx)];
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
in n;
cin>>n;
in s;
forn(i,n){
cin>>s;
pr(s);
}
in t=0;
fors(i,mp){
if(i->first.x==1)
++sm;
else
t+=max(i->second,mp[i->first.sp()]);
}
sm+=t/2;
cout<<sm<<endl;
return 0;
}
```

#### Submission Info

Submission Time 2016-08-21 21:33:49+0900 D - Anticube w4yneb0t C++14 (GCC 5.4.1) 1100 1825 Byte AC 4459 ms 10624 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 4360 ms 256 KB
02.txt AC 4364 ms 256 KB
03.txt AC 4373 ms 256 KB
04.txt AC 4358 ms 256 KB
05.txt AC 4356 ms 256 KB
06.txt AC 4364 ms 256 KB
07.txt AC 4360 ms 256 KB
08.txt AC 4353 ms 256 KB
09.txt AC 4359 ms 256 KB
10.txt AC 4353 ms 256 KB
11.txt AC 4424 ms 256 KB
12.txt AC 4449 ms 256 KB
13.txt AC 4458 ms 1408 KB
14.txt AC 4457 ms 1408 KB
15.txt AC 4459 ms 1408 KB
16.txt AC 4456 ms 1408 KB
17.txt AC 164 ms 256 KB
18.txt AC 164 ms 256 KB
19.txt AC 161 ms 256 KB
20.txt AC 163 ms 256 KB
21.txt AC 3369 ms 896 KB
22.txt AC 3364 ms 896 KB
23.txt AC 3361 ms 896 KB
24.txt AC 3378 ms 896 KB
25.txt AC 3376 ms 896 KB
26.txt AC 3357 ms 896 KB
27.txt AC 2345 ms 10624 KB
28.txt AC 16 ms 256 KB
29.txt AC 43 ms 256 KB
30.txt AC 66 ms 256 KB
31.txt AC 64 ms 256 KB
32.txt AC 64 ms 256 KB
33.txt AC 4 ms 256 KB
34.txt AC 140 ms 256 KB
35.txt AC 129 ms 256 KB
36.txt AC 4 ms 256 KB
37.txt AC 4269 ms 384 KB
38.txt AC 4253 ms 384 KB
39.txt AC 4244 ms 384 KB
40.txt AC 4252 ms 384 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