Submission #846827


Source Code Expand

Copy
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; ++i)

const int N = (int) 1e5 + 5, mod = 0;

int pr[N];
long long a[N];
vector<int> p;
map<long long, int> mp;
long long s[N], o[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    for (int i = 2; i < N; ++i) if (!pr[i]) {
        for (int j = i; j < N; j += i)
            pr[j] = 0;
        p.push_back(i);
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        long long x = a[i], y = 1, self = 1;
        for (int j : p) {
            if (j * 1ll * j * j > x) {
                break;
            }
            int cnt = 0;
            while (x % j == 0) cnt++, cnt %= 3, x /= j;
            for (int q = 0; q < cnt; ++q)
                self *= j;
            for (int q = 0; q < (3 - cnt) % 3; ++q)
                y *= j;
        }
        self *= x;
        long long sq = sqrt(x);
        int flag = 0;
        for (long long q = sq - 1; q <= sq + 1; ++q)
            if (q * q == x) {
                flag = 1;
                sq = q;
                break;
            }
        if (!flag)
            y *= x * x;
        else
            y *= sq;
        s[i] = self;
        o[i] = y;
        mp[self]++;
        mp[y]--;
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (mp[s[i]] >= 0) {
            res++;
            mp[o[i]] = -1;
        }
    }
    cout << res;





}

Submission Info

Submission Time
Task D - Anticube
User Reyna
Language C++14 (GCC 5.4.1)
Score 1100
Code Size 1856 Byte
Status AC
Exec Time 3052 ms
Memory 15864 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 1209 ms 15864 KB
02.txt AC 1228 ms 15864 KB
03.txt AC 1203 ms 15864 KB
04.txt AC 1229 ms 15864 KB
05.txt AC 1238 ms 15864 KB
06.txt AC 1191 ms 15864 KB
07.txt AC 1173 ms 15864 KB
08.txt AC 1194 ms 15864 KB
09.txt AC 1188 ms 15864 KB
10.txt AC 1202 ms 15864 KB
11.txt AC 3002 ms 7288 KB
12.txt AC 3052 ms 7288 KB
13.txt AC 792 ms 7288 KB
14.txt AC 584 ms 7288 KB
15.txt AC 584 ms 7288 KB
16.txt AC 587 ms 7288 KB
17.txt AC 119 ms 3448 KB
18.txt AC 125 ms 3448 KB
19.txt AC 121 ms 3448 KB
20.txt AC 121 ms 3448 KB
21.txt AC 1283 ms 10872 KB
22.txt AC 1255 ms 10872 KB
23.txt AC 1261 ms 10872 KB
24.txt AC 1254 ms 10872 KB
25.txt AC 1251 ms 10872 KB
26.txt AC 1249 ms 10872 KB
27.txt AC 177 ms 13688 KB
28.txt AC 24 ms 3448 KB
29.txt AC 37 ms 3448 KB
30.txt AC 32 ms 3448 KB
31.txt AC 34 ms 3448 KB
32.txt AC 34 ms 3448 KB
33.txt AC 10 ms 1276 KB
34.txt AC 118 ms 3448 KB
35.txt AC 106 ms 3448 KB
36.txt AC 10 ms 1276 KB
37.txt AC 2721 ms 8184 KB
38.txt AC 2717 ms 8184 KB
39.txt AC 2713 ms 8184 KB
40.txt AC 2715 ms 8184 KB
41.txt AC 10 ms 1276 KB
42.txt AC 10 ms 1276 KB
43.txt AC 10 ms 1276 KB
44.txt AC 10 ms 1276 KB
45.txt AC 10 ms 1276 KB
46.txt AC 12 ms 1276 KB
47.txt AC 10 ms 1276 KB
48.txt AC 10 ms 1276 KB
s1.txt AC 10 ms 1276 KB
s2.txt AC 10 ms 1276 KB
s3.txt AC 10 ms 1276 KB