Submission #1301748
Source Code Expand
#include<iostream> #include<vector> #include<algorithm> #include<cmath> using namespace std; long long n, s[100000], t[100000], K, ret, inf = (1LL << 40), num[2]; vector<pair<long long, int>>vec[3200000]; bool used[100000]; vector<bool>vec2[3200000]; long long solve(long long I) { long long ret = 1; for (long long i = 2; i*i*i <= I; i++) { long long U = 0; while (I%i == 0) { I /= i; U++; U %= 3; } for (int j = 0; j < (3 - U % 3) % 3; j++) { if (ret*i <= inf)ret *= i; else ret = inf; } } long long G = (1.0L*sqrtl(1.0L*I) + 0.5L); if (G*G == I) { ret *= G; } else { for (int i = 0; i < 2; i++) { if ((inf / I) >= ret)ret *= I; else ret = inf; } } return min(ret, inf); } void dfs(int pos, int depth) { if (used[pos] == true)return; num[depth]++; used[pos] = true; for (int i = 1; i <= 2000; i++) { long long P = 1LL * i*i*i*t[pos]; if (P > 10000000000LL)break; int B = (P >> 12); if (vec[B].size() == 0)continue; int pos1 = lower_bound(vec[B].begin(), vec[B].end(), make_pair(P, 0)) - vec[B].begin(); if (pos1 >= vec[B].size() || vec[B][pos1].first != P || vec2[B][pos1] == true)continue; vec2[B][pos1] = true; while (pos1 < vec[B].size() && vec[B][pos1].first == P) { dfs(vec[B][pos1].second, depth ^ 1); pos1++; } } } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> s[i]; t[i] = solve(s[i]); if (t[i] != 1)vec[s[i] >> 12].push_back(make_pair(s[i], i)); else K = 1; } for (int i = 0; i < 3200000; i++) { sort(vec[i].begin(), vec[i].end()); vec2[i].resize(vec[i].size()); } for (int i = 0; i < n; i++) { if (t[i] == 1 || used[i] == true)continue; num[0] = 0; num[1] = 0; dfs(i, 0); ret += max(num[0], num[1]); } cout << ret + K << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Anticube |
User | E869120 |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 1773 Byte |
Status | AC |
Exec Time | 1857 ms |
Memory | 208128 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1100 / 1100 | ||||
Status |
|
|
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 | 720 ms | 208000 KB |
02.txt | AC | 721 ms | 208000 KB |
03.txt | AC | 721 ms | 208000 KB |
04.txt | AC | 721 ms | 208128 KB |
05.txt | AC | 723 ms | 208128 KB |
06.txt | AC | 719 ms | 208000 KB |
07.txt | AC | 714 ms | 208128 KB |
08.txt | AC | 719 ms | 208000 KB |
09.txt | AC | 721 ms | 208000 KB |
10.txt | AC | 718 ms | 208000 KB |
11.txt | AC | 1857 ms | 205312 KB |
12.txt | AC | 1855 ms | 205312 KB |
13.txt | AC | 393 ms | 204160 KB |
14.txt | AC | 396 ms | 204288 KB |
15.txt | AC | 398 ms | 204160 KB |
16.txt | AC | 398 ms | 204160 KB |
17.txt | AC | 577 ms | 204288 KB |
18.txt | AC | 577 ms | 204288 KB |
19.txt | AC | 575 ms | 204288 KB |
20.txt | AC | 574 ms | 204288 KB |
21.txt | AC | 888 ms | 206208 KB |
22.txt | AC | 888 ms | 206208 KB |
23.txt | AC | 887 ms | 206208 KB |
24.txt | AC | 886 ms | 206208 KB |
25.txt | AC | 895 ms | 206208 KB |
26.txt | AC | 889 ms | 206208 KB |
27.txt | AC | 166 ms | 203520 KB |
28.txt | AC | 109 ms | 201856 KB |
29.txt | AC | 116 ms | 201856 KB |
30.txt | AC | 397 ms | 203636 KB |
31.txt | AC | 390 ms | 203636 KB |
32.txt | AC | 386 ms | 203760 KB |
33.txt | AC | 92 ms | 200960 KB |
34.txt | AC | 312 ms | 203636 KB |
35.txt | AC | 179 ms | 201856 KB |
36.txt | AC | 92 ms | 200960 KB |
37.txt | AC | 1691 ms | 205568 KB |
38.txt | AC | 1693 ms | 205568 KB |
39.txt | AC | 1691 ms | 205568 KB |
40.txt | AC | 1695 ms | 205568 KB |
41.txt | AC | 92 ms | 200960 KB |
42.txt | AC | 92 ms | 200960 KB |
43.txt | AC | 92 ms | 200960 KB |
44.txt | AC | 92 ms | 200960 KB |
45.txt | AC | 92 ms | 200960 KB |
46.txt | AC | 92 ms | 200960 KB |
47.txt | AC | 92 ms | 200960 KB |
48.txt | AC | 92 ms | 200960 KB |
s1.txt | AC | 92 ms | 200960 KB |
s2.txt | AC | 92 ms | 200960 KB |
s3.txt | AC | 92 ms | 200960 KB |