Submission #1533296


Source Code Expand

#include "bits/stdc++.h"
using namespace std;

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

//V以下の素数列挙。O(V log log V)
int V = 101010;
vector<int> prime;
void init() {
        vector<bool> is_prime(V + 1, true);
        is_prime[0] = is_prime[1] = false;
        for (int i = 2; i <= V; i ++) {
                if (is_prime[i]) {
                        prime.push_back(i);
                        for (int j = i + i; j <= V; j += i) is_prime[j] = false;
                }
        }
}

int main() {
        init();
        int n;
        cin >> n;
        vector<ll> a(n);
        for (int i = 0; i < n; i ++) cin >> a[i];
        unordered_map<ll, pll> cnts; //その数字の個数と、その数字のペア的なやつの数
        for (auto v : a) {
                ll val = 1, another = 1;
                for (auto p : prime) {
                        if (v % p != 0) continue;
                        int cnt = 0;
                        while (v % p == 0) {
                                cnt ++;
                                v /= p;
                        }
                        cnt %= 3;
                        if (cnt == 1) {
                                val *= p;
                                another *= p * p;
                        } else if (cnt == 2) {
                                val *= p * p;
                                another *= p;
                        }
                }
                if (v > 1) {
                        val *= v;
                        another *= v * v;
                }
                cnts[val].second = another;
                cnts[val].first ++;
        }
        auto tmp = cnts;
        ll ans = 0;
        for (auto u : tmp) if (u.first != 1 && cnts[u.second.second] < u.second) ans += u.second.first;
        if (cnts[1].first != 0) ans ++;
        cout << ans << endl;
        return 0;
}

Submission Info

Submission Time
Task D - Anticube
User KokiYmgch
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2119 Byte
Status TLE
Exec Time 5256 ms
Memory 3980 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
AC × 3
AC × 13
TLE × 38
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 5255 ms 3980 KB
02.txt TLE 5255 ms 3980 KB
03.txt TLE 5256 ms 3980 KB
04.txt TLE 5256 ms 3980 KB
05.txt TLE 5255 ms 3980 KB
06.txt TLE 5255 ms 3980 KB
07.txt TLE 5255 ms 3980 KB
08.txt TLE 5255 ms 3980 KB
09.txt TLE 5255 ms 3980 KB
10.txt TLE 5256 ms 3980 KB
11.txt TLE 5255 ms 2560 KB
12.txt TLE 5255 ms 2560 KB
13.txt TLE 5255 ms 2688 KB
14.txt TLE 5255 ms 2688 KB
15.txt TLE 5255 ms 2688 KB
16.txt TLE 5255 ms 2688 KB
17.txt TLE 5255 ms 1152 KB
18.txt TLE 5255 ms 1152 KB
19.txt TLE 5255 ms 1152 KB
20.txt TLE 5255 ms 1152 KB
21.txt TLE 5255 ms 3328 KB
22.txt TLE 5255 ms 3212 KB
23.txt TLE 5255 ms 3212 KB
24.txt TLE 5255 ms 3212 KB
25.txt TLE 5255 ms 3212 KB
26.txt TLE 5255 ms 3212 KB
27.txt TLE 5255 ms 3596 KB
28.txt TLE 5255 ms 1152 KB
29.txt TLE 5255 ms 1152 KB
30.txt TLE 5255 ms 1152 KB
31.txt TLE 5255 ms 1152 KB
32.txt TLE 5255 ms 1152 KB
33.txt AC 2 ms 384 KB
34.txt TLE 5255 ms 1152 KB
35.txt TLE 5255 ms 1152 KB
36.txt AC 2 ms 384 KB
37.txt TLE 5255 ms 2688 KB
38.txt TLE 5255 ms 2688 KB
39.txt TLE 5255 ms 2688 KB
40.txt TLE 5255 ms 2688 KB
41.txt AC 2 ms 384 KB
42.txt AC 2 ms 384 KB
43.txt AC 2 ms 384 KB
44.txt AC 2 ms 384 KB
45.txt AC 2 ms 384 KB
46.txt AC 2 ms 384 KB
47.txt AC 2 ms 384 KB
48.txt AC 2 ms 384 KB
s1.txt AC 3 ms 384 KB
s2.txt AC 2 ms 384 KB
s3.txt AC 3 ms 384 KB