Submission #846132


Source Code Expand

Copy
// tested by Hightail: https://github.com/dj3500/hightail
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <stack>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define INF 1001001001
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define mp make_pair
#define pii pair<int,int>
#define ll long long
#define vi vector<int>
#define SZ(x) ((int)((x).size()))
#define fi first
#define se second
#define wez(n) int (n); scanf("%d",&(n));
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
inline void pisz(int n) { printf("%d\n",n); }
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){FOR(i,SZ(t))s<<t[i]<<" ";return s; }
#define DBG(vari) cout<<"["<<__LINE__<<"] "<<#vari<<" = "<<(vari)<<endl;
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (__typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define TESTS wez(testow)while(testow--)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define IOS ios_base::sync_with_stdio(0);

typedef vector<pair<ll,int> > Roz;
Roz rozklad (ll x) { // rozklad: {<liczba pierwsza, krotnosc>}
   Roz res;
   for (int d = 2; (ll)d*d <= x; ++d) {
      if (x % d == 0) {
         int k = 0;
         while (x % d == 0) { x /= d; ++k; }
         res.pb(mp(d,k));
      }
   }
   if (x != 1) res.pb(mp(x,1));
   return res;
}

int main () {
   IOS
   int n;
   cin >> n;
   bool has1 = 0;
   map<ll,int> m;
   map<ll,ll> para;
   FOR(i,n) {
      ll x;
      cin >> x;
      Roz roz = rozklad(x);
      x = 1;
      ll p = 1;
      for (auto it : roz) {
         int krot = it.se % 3;
         if (krot) { // 1 or 2
            FOR(u,krot) {
               x *= it.fi;
            }
            FOR(u,3-krot) {
               p *= it.fi;
            }
         }
      }
      if (x == 1) {
         has1 = 1;
      } else {
         m[x]++;
         m[p];
         para[x] = p;
      }
   }
   int res = has1;
   for (auto it : m) {
      ll x = it.fi;
      ll p = para[x];
      if (x < p) {
         res += max(it.se, m[p]);
      }
   }
   cout << res;
}

Submission Info

Submission Time
Task D - Anticube
User dj3500
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2687 Byte
Status WA
Exec Time 5257 ms
Memory 20864 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
AC × 3
AC × 23
WA × 2
TLE × 26
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 TLE 5257 ms 6144 KB
02.txt TLE 5254 ms 5888 KB
03.txt TLE 5257 ms 6144 KB
04.txt TLE 5254 ms 6144 KB
05.txt TLE 5254 ms 6144 KB
06.txt TLE 5254 ms 6016 KB
07.txt TLE 5254 ms 6272 KB
08.txt TLE 5254 ms 6144 KB
09.txt TLE 5254 ms 6016 KB
10.txt TLE 5254 ms 6272 KB
11.txt TLE 5253 ms 1024 KB
12.txt TLE 5253 ms 1024 KB
13.txt TLE 5257 ms 4864 KB
14.txt TLE 5253 ms 4864 KB
15.txt TLE 5253 ms 4864 KB
16.txt TLE 5257 ms 4864 KB
17.txt AC 126 ms 256 KB
18.txt AC 126 ms 256 KB
19.txt AC 126 ms 256 KB
20.txt AC 126 ms 256 KB
21.txt TLE 5253 ms 2304 KB
22.txt TLE 5253 ms 2304 KB
23.txt TLE 5257 ms 2304 KB
24.txt TLE 5253 ms 2304 KB
25.txt TLE 5253 ms 2304 KB
26.txt TLE 5253 ms 2304 KB
27.txt AC 350 ms 20864 KB
28.txt AC 15 ms 256 KB
29.txt AC 33 ms 256 KB
30.txt WA 45 ms 256 KB
31.txt AC 43 ms 256 KB
32.txt AC 43 ms 256 KB
33.txt AC 4 ms 256 KB
34.txt AC 116 ms 256 KB
35.txt AC 105 ms 256 KB
36.txt AC 4 ms 256 KB
37.txt TLE 5253 ms 1152 KB
38.txt TLE 5254 ms 1152 KB
39.txt TLE 5257 ms 1152 KB
40.txt TLE 5257 ms 1152 KB
41.txt AC 4 ms 256 KB
42.txt AC 4 ms 256 KB
43.txt AC 5 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 WA 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 5 ms 256 KB