Submission #1515710


Source Code Expand

#include <bits/stdc++.h>
#include <math.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9

using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
const int N = 100010;
const int mod = 1e9 + 7;
ll a[N], b[N], aa[N], bb[N];
map<ll, int> Mp;
vector<int> p;
bool vis[N];
int main()
{
    int n,ans = 0;
    rep(i, 2, N - 1)
        if (!vis[i])
        {
            p.push_back(i);
            for (int j = i + i; j < N; j += i) vis[j] = 1;
        }
    cin >> n;
    rep(i, 0, n - 1)
    {
        cin >> a[i];
        b[i] = a[i];
    }
    rep(i, 0, n - 1)
    {
        aa[i] = 1, bb[i] = 1;
        int nn = p.size();
        rep(j, 0, nn - 1)
        {
            int cnt = 0;
            while (a[i] % p[j] == 0)
            {
                a[i] /= p[j];
                cnt ++;
            }
            if (cnt % 3 == 1) aa[i] *= p[j], bb[i] *= p[j] * p[j];
           	else if (cnt % 3 == 2) bb[i] *= p[j], aa[i] *= p[j] * p[j];
        }
        aa[i] *= a[i];
        ll t = floor(sqrt(a[i] * 1.0));
        if (t * t == a[i]) bb[i] *= t;
        else
        {
            if (bb[i] * a[i] > 0 && bb[i] * a[i] * a[i] > 0) bb[i] *= a[i] * a[i];
            else bb[i] = 0;
        }
        Mp[aa[i]] ++;
    }
    int flag = 0;
    rep(i, 0, n - 1)
    {
        if (aa[i] == 1)
        {
            if (flag == 0) ans ++, flag = 1;
        }
        else ans += max(Mp[aa[i]], Mp[bb[i]]), Mp[aa[i]] = Mp[bb[i]] = 0;
    }
    cout << ans;
    return 0;
}

Submission Info

Submission Time
Task D - Anticube
User lzr156
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2119 Byte
Status TLE
Exec Time 5260 ms
Memory 6016 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 5256 ms 6016 KB
02.txt TLE 5256 ms 6016 KB
03.txt TLE 5256 ms 6016 KB
04.txt TLE 5256 ms 6016 KB
05.txt TLE 5256 ms 6016 KB
06.txt TLE 5256 ms 6016 KB
07.txt TLE 5256 ms 6016 KB
08.txt TLE 5255 ms 6016 KB
09.txt TLE 5256 ms 6016 KB
10.txt TLE 5256 ms 6016 KB
11.txt TLE 5256 ms 4352 KB
12.txt TLE 5256 ms 4352 KB
13.txt TLE 5256 ms 4608 KB
14.txt TLE 5256 ms 4608 KB
15.txt TLE 5255 ms 4608 KB
16.txt TLE 5260 ms 4608 KB
17.txt TLE 5255 ms 2816 KB
18.txt TLE 5255 ms 2816 KB
19.txt TLE 5255 ms 2816 KB
20.txt TLE 5255 ms 2816 KB
21.txt TLE 5256 ms 4992 KB
22.txt TLE 5255 ms 4992 KB
23.txt TLE 5256 ms 4992 KB
24.txt TLE 5256 ms 4992 KB
25.txt TLE 5256 ms 4992 KB
26.txt TLE 5256 ms 4992 KB
27.txt TLE 5256 ms 5504 KB
28.txt TLE 5255 ms 2944 KB
29.txt TLE 5255 ms 2816 KB
30.txt TLE 5255 ms 2816 KB
31.txt TLE 5255 ms 2816 KB
32.txt TLE 5255 ms 2816 KB
33.txt AC 2 ms 512 KB
34.txt TLE 5255 ms 2816 KB
35.txt TLE 5255 ms 2816 KB
36.txt AC 2 ms 512 KB
37.txt TLE 5256 ms 4608 KB
38.txt TLE 5255 ms 4608 KB
39.txt TLE 5256 ms 4608 KB
40.txt TLE 5256 ms 4608 KB
41.txt AC 2 ms 512 KB
42.txt AC 2 ms 512 KB
43.txt AC 2 ms 512 KB
44.txt AC 2 ms 512 KB
45.txt AC 2 ms 512 KB
46.txt AC 2 ms 512 KB
47.txt AC 2 ms 512 KB
48.txt AC 2 ms 512 KB
s1.txt AC 3 ms 512 KB
s2.txt AC 2 ms 512 KB
s3.txt AC 3 ms 512 KB