Submission #1301747
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 <= s[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 | 0 |
Code Size | 1776 Byte |
Status | WA |
Exec Time | 2618 ms |
Memory | 208128 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 704 ms | 208000 KB |
02.txt | AC | 629 ms | 208000 KB |
03.txt | AC | 602 ms | 208000 KB |
04.txt | AC | 390 ms | 208000 KB |
05.txt | AC | 591 ms | 208128 KB |
06.txt | AC | 496 ms | 208000 KB |
07.txt | AC | 348 ms | 208128 KB |
08.txt | AC | 726 ms | 208128 KB |
09.txt | AC | 283 ms | 208000 KB |
10.txt | AC | 608 ms | 208000 KB |
11.txt | AC | 530 ms | 205312 KB |
12.txt | AC | 609 ms | 205312 KB |
13.txt | AC | 211 ms | 204160 KB |
14.txt | AC | 217 ms | 204288 KB |
15.txt | AC | 194 ms | 204160 KB |
16.txt | AC | 179 ms | 204160 KB |
17.txt | WA | 632 ms | 204288 KB |
18.txt | WA | 610 ms | 204288 KB |
19.txt | WA | 623 ms | 204288 KB |
20.txt | AC | 652 ms | 204288 KB |
21.txt | AC | 302 ms | 206208 KB |
22.txt | WA | 332 ms | 206208 KB |
23.txt | AC | 306 ms | 206208 KB |
24.txt | WA | 314 ms | 206208 KB |
25.txt | AC | 322 ms | 206208 KB |
26.txt | AC | 330 ms | 206208 KB |
27.txt | WA | 140 ms | 203520 KB |
28.txt | AC | 115 ms | 201856 KB |
29.txt | WA | 122 ms | 201856 KB |
30.txt | AC | 406 ms | 203636 KB |
31.txt | WA | 398 ms | 203636 KB |
32.txt | WA | 394 ms | 203636 KB |
33.txt | AC | 99 ms | 200960 KB |
34.txt | AC | 2618 ms | 203636 KB |
35.txt | WA | 1250 ms | 201856 KB |
36.txt | WA | 98 ms | 200960 KB |
37.txt | AC | 339 ms | 205568 KB |
38.txt | AC | 248 ms | 205568 KB |
39.txt | WA | 296 ms | 205568 KB |
40.txt | AC | 305 ms | 205568 KB |
41.txt | AC | 99 ms | 200960 KB |
42.txt | AC | 98 ms | 200960 KB |
43.txt | WA | 99 ms | 200960 KB |
44.txt | AC | 99 ms | 200960 KB |
45.txt | AC | 98 ms | 201088 KB |
46.txt | AC | 98 ms | 200960 KB |
47.txt | WA | 99 ms | 200960 KB |
48.txt | AC | 98 ms | 200960 KB |
s1.txt | WA | 99 ms | 200960 KB |
s2.txt | AC | 99 ms | 200960 KB |
s3.txt | AC | 99 ms | 200960 KB |