Submission #1189131
Source Code Expand
#include <iostream> #include <vector> #include <set> #include <map> #include <cmath> using namespace std; typedef long long ll; const ll p = 1000000009; void Sito(vector<int>& P) { vector<bool> p(2500, true); p[0] = p[1] = false; for (int i = 2; i < 2500; ++i) if (p[i]) for (int j = 2 * i; j < 2500; j += i) p[j] = false; for (int i = 0; i < 2500; ++i) if (p[i]) P.push_back(i); } ll Hasz(vector<ll>& a) { ll h = 0; for (int i = 0; i < a.size(); ++i) h = h * p + a[i]; return h; } bool Kw(ll x) { ll pie = sqrt(x); if (pie * pie == x) return true; return false; } int main() { ios_base::sync_with_stdio(0); vector<int> P; Sito(P); int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; map<ll, ll> M; multiset< pair<ll, ll> > S; bool jed = false; for (int i = 0; i < n; ++i) { vector<ll> po, wyk; for (int j = 0; j < P.size(); ++j) { int il = 0; while (a[i] % P[j] == 0) { a[i] /= P[j]; ++il; } if (il % 3 != 0) { po.push_back(P[j]); wyk.push_back(il % 3); } } if (a[i] != 1) { if (Kw(a[i])) { po.push_back(sqrt(a[i])); wyk.push_back(2); } else { po.push_back(a[i]); wyk.push_back(1); } } if (po.size() == 0) { jed = true; continue; } vector<ll> odp; for (int j = 0; j < wyk.size(); ++j) { if (wyk[j] == 1) odp.push_back(2); if (wyk[j] == 2) odp.push_back(1); } ll hpo = Hasz(po); ll hwyk = Hasz(wyk); ll hodp = Hasz(odp); M[hwyk] = hodp; M[hodp] = hwyk; S.insert(make_pair(hpo, hwyk)); } int odp = 0; while (S.size() != 0) { pair<ll, ll> a = *S.begin(); int il1 = 0; while (S.size() != 0 && (*S.begin()).first == a.first && (*S.begin()).second == a.second) { S.erase(S.begin()); ++il1; } pair<ll, ll> b = make_pair(a.first, M[a.second]); int il2 = 0; while (S.size() != 0 && S.find(b) != S.end()) { S.erase(b); ++il2; } odp += max(il1, il2); } if (jed) ++odp; cout << odp; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Anticube |
User | ArturSocha |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2810 Byte |
Status | WA |
Exec Time | 501 ms |
Memory | 7296 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 | 490 ms | 7296 KB |
02.txt | AC | 487 ms | 7296 KB |
03.txt | AC | 489 ms | 7296 KB |
04.txt | AC | 488 ms | 7296 KB |
05.txt | AC | 489 ms | 7296 KB |
06.txt | AC | 489 ms | 7296 KB |
07.txt | AC | 491 ms | 7296 KB |
08.txt | AC | 488 ms | 7296 KB |
09.txt | AC | 488 ms | 7296 KB |
10.txt | AC | 492 ms | 7296 KB |
11.txt | AC | 454 ms | 7296 KB |
12.txt | AC | 453 ms | 7296 KB |
13.txt | WA | 456 ms | 7296 KB |
14.txt | WA | 458 ms | 7296 KB |
15.txt | WA | 454 ms | 7296 KB |
16.txt | WA | 455 ms | 7296 KB |
17.txt | WA | 499 ms | 7168 KB |
18.txt | WA | 499 ms | 7168 KB |
19.txt | WA | 500 ms | 7168 KB |
20.txt | WA | 501 ms | 7168 KB |
21.txt | WA | 490 ms | 7296 KB |
22.txt | WA | 487 ms | 7296 KB |
23.txt | WA | 481 ms | 7296 KB |
24.txt | WA | 480 ms | 7296 KB |
25.txt | WA | 481 ms | 7296 KB |
26.txt | WA | 483 ms | 7296 KB |
27.txt | WA | 479 ms | 7296 KB |
28.txt | AC | 403 ms | 1024 KB |
29.txt | AC | 409 ms | 1024 KB |
30.txt | AC | 456 ms | 7296 KB |
31.txt | AC | 457 ms | 7296 KB |
32.txt | AC | 458 ms | 7296 KB |
33.txt | AC | 1 ms | 256 KB |
34.txt | AC | 493 ms | 7296 KB |
35.txt | AC | 442 ms | 1024 KB |
36.txt | AC | 1 ms | 256 KB |
37.txt | WA | 459 ms | 7296 KB |
38.txt | WA | 458 ms | 7296 KB |
39.txt | WA | 458 ms | 7296 KB |
40.txt | WA | 458 ms | 7296 KB |
41.txt | AC | 1 ms | 256 KB |
42.txt | AC | 1 ms | 256 KB |
43.txt | AC | 1 ms | 256 KB |
44.txt | AC | 1 ms | 256 KB |
45.txt | AC | 1 ms | 256 KB |
46.txt | AC | 1 ms | 256 KB |
47.txt | AC | 1 ms | 256 KB |
48.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 1 ms | 256 KB |