Contest Duration: - (local time) (110 minutes) Back to Home

Submission #846054

Source Code Expand

Copy
```#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

typedef long long ll;

using namespace std;

const int MX = 2155;
const int MAXN = 1 << 18;
const int MOD = 1; // 1000 * 1000 * 1000 + 7;
const int INF = 2e9;
const double PI = acos(-1.0);

bool isPrime(int x) {
for (int i = 2; i * i <= x; i++) if (x % i == 0) return 0;
return 1;
}

int main() {
#ifdef _MSC_VER
freopen("input.txt", "r", stdin);
#endif

vector<int> pr;
for (int i = 2; i <= MX; i++) if (isPrime(i)) pr.push_back(i);

int n;
while (cin >> n) {
vector<ll> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}

int ans = 0;
vector<vector<pair<int, int> > > mem(n);
map<vector<pair<int, int> >, int> mp;
set<vector<pair<int, int> > > used;
for (int i = 0; i < n; i++) {
ll x = a[i];
vector<pair<int, int> > cur;
for (int j = 0; j < (int)pr.size(); j++) {
if (x % pr[j] == 0) {
int cnt = 0;
while (x % pr[j] == 0) {
x /= pr[j];
cnt++;
}
if (cnt % 3 != 0) cur.push_back(make_pair(pr[j], cnt % 3));
}
}
if (x != 1) cur.push_back(make_pair(MX + i, 1));
if (cur.empty()) {
if (ans == 0) {
ans++;
}
}
else {
mem[i] = cur;
mp[cur]++;
}
}

for (int i = 0; i < n; i++) {
if (mem[i].empty()) continue;
vector<pair<int, int> > cur = mem[i];
if (used.find(cur) != used.end()) continue;
vector<pair<int, int> > oth = cur;
for (int j = 0; j < (int)oth.size(); j++) {
oth[j].second = 3 - oth[j].second;
}
ans += max(mp[cur], mp[oth]);
used.insert(cur);
used.insert(oth);
}
cout << ans << endl;
}

return 0;
}```

#### Submission Info

Submission Time 2016-08-21 21:27:28+0900 D - Anticube izban C++14 (GCC 5.4.1) 0 1989 Byte WA 1486 ms 50304 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
 AC × 3
 AC × 37 WA × 14
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 1438 ms 50304 KB
02.txt AC 1437 ms 50304 KB
03.txt AC 1441 ms 50304 KB
04.txt AC 1440 ms 50304 KB
05.txt AC 1450 ms 50304 KB
06.txt AC 1451 ms 50304 KB
07.txt AC 1447 ms 50304 KB
08.txt AC 1447 ms 50304 KB
09.txt AC 1472 ms 50304 KB
10.txt AC 1486 ms 50304 KB
11.txt AC 1015 ms 47104 KB
12.txt AC 1010 ms 47104 KB
13.txt WA 968 ms 46848 KB
14.txt WA 966 ms 46848 KB
15.txt WA 971 ms 46848 KB
16.txt WA 967 ms 46848 KB
17.txt AC 785 ms 6656 KB
18.txt AC 785 ms 6656 KB
19.txt AC 784 ms 6656 KB
20.txt AC 786 ms 6656 KB
21.txt WA 1050 ms 37760 KB
22.txt WA 1049 ms 37760 KB
23.txt WA 1058 ms 37760 KB
24.txt WA 1049 ms 37760 KB
25.txt WA 1052 ms 37760 KB
26.txt WA 1064 ms 37760 KB
27.txt AC 1245 ms 41984 KB
28.txt AC 615 ms 3328 KB
29.txt AC 625 ms 3328 KB
30.txt AC 663 ms 6528 KB
31.txt AC 665 ms 6528 KB
32.txt AC 665 ms 6528 KB
33.txt AC 4 ms 256 KB
34.txt AC 772 ms 6528 KB
35.txt AC 740 ms 3328 KB
36.txt AC 4 ms 256 KB
37.txt WA 998 ms 45568 KB
38.txt WA 999 ms 45568 KB
39.txt WA 998 ms 45568 KB
40.txt WA 997 ms 45568 KB
41.txt AC 4 ms 256 KB
42.txt AC 4 ms 256 KB
43.txt AC 4 ms 256 KB
44.txt AC 4 ms 256 KB
45.txt AC 4 ms 256 KB
46.txt AC 4 ms 256 KB
47.txt AC 4 ms 256 KB
48.txt AC 4 ms 256 KB
s1.txt AC 4 ms 256 KB
s2.txt AC 4 ms 256 KB
s3.txt AC 4 ms 256 KB