Submission #846916


Source Code Expand

Copy
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <map>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

int main() {
  vector<char> primes_(100000 + 10, 1);
  vector<int> primes;
  for (int i = 2; i <= 100000; ++i) {
    if (!primes_[i]) continue;
    primes.push_back(i);
    for (int j = i * 2; j < 100000; j += i) primes_[j] = 0;
  }

  int N;
  while (scanf("%d", &N) != EOF) {
    map<vector<ll>, int> cnt;

    for (int i : range(N)) {
      ll x;
      scanf("%lld", &x);

      vector<ll> v;
      for (int i : primes) {
        if (x % i != 0) continue;
        ll r = 0;
        while (x % i == 0) {
          x /= i;
          r = (r + 1) % 3;
        }
        if (r) {
          v.push_back(i);
          v.push_back(r);
        }
      }
      if (x > 1) {
        v.push_back(x);
        v.push_back(1);
      }

      //for (auto y : v) cout << y << " " ;
      //cout << endl;
      cnt[v]++;
    }

    ll res = 0;
    for (auto& it : cnt) {
      vector<ll> now = it.first, cmp = now;
      if (now.size() == 0) {
        // special element
        res += 1;
        continue;
      }

      for (int i = 1; i < cmp.size(); i += 2) cmp[i] = 3 - cmp[i];
      if (cnt.find(cmp) != cnt.end() && now > cmp) continue;

      res += max(it.second, cnt[cmp]);
    }
    printf("%lld\n", res);
  }
}

Submission Info

Submission Time
Task D - Anticube
User ir5
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1758 Byte
Status TLE
Exec Time 5257 ms
Memory 4992 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:32:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
       scanf("%lld", &x);
                        ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
AC × 3
AC × 13
TLE × 38
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 TLE 5257 ms 4992 KB
02.txt TLE 5253 ms 4992 KB
03.txt TLE 5253 ms 4992 KB
04.txt TLE 5253 ms 4992 KB
05.txt TLE 5253 ms 4992 KB
06.txt TLE 5257 ms 4992 KB
07.txt TLE 5253 ms 4992 KB
08.txt TLE 5254 ms 4992 KB
09.txt TLE 5253 ms 4992 KB
10.txt TLE 5254 ms 4992 KB
11.txt TLE 5253 ms 2560 KB
12.txt TLE 5253 ms 2560 KB
13.txt TLE 5257 ms 2688 KB
14.txt TLE 5257 ms 2688 KB
15.txt TLE 5253 ms 2816 KB
16.txt TLE 5257 ms 2688 KB
17.txt TLE 5257 ms 384 KB
18.txt TLE 5253 ms 384 KB
19.txt TLE 5253 ms 384 KB
20.txt TLE 5253 ms 384 KB
21.txt TLE 5257 ms 3072 KB
22.txt TLE 5253 ms 3072 KB
23.txt TLE 5253 ms 3072 KB
24.txt TLE 5253 ms 3072 KB
25.txt TLE 5253 ms 3072 KB
26.txt TLE 5253 ms 3072 KB
27.txt TLE 5253 ms 3840 KB
28.txt TLE 5253 ms 384 KB
29.txt TLE 5253 ms 384 KB
30.txt TLE 5253 ms 384 KB
31.txt TLE 5253 ms 384 KB
32.txt TLE 5253 ms 384 KB
33.txt AC 5 ms 384 KB
34.txt TLE 5253 ms 384 KB
35.txt TLE 5253 ms 384 KB
36.txt AC 5 ms 384 KB
37.txt TLE 5253 ms 2816 KB
38.txt TLE 5253 ms 2816 KB
39.txt TLE 5253 ms 2816 KB
40.txt TLE 5253 ms 2816 KB
41.txt AC 6 ms 384 KB
42.txt AC 6 ms 384 KB
43.txt AC 6 ms 384 KB
44.txt AC 6 ms 384 KB
45.txt AC 6 ms 384 KB
46.txt AC 5 ms 384 KB
47.txt AC 6 ms 384 KB
48.txt AC 6 ms 384 KB
s1.txt AC 7 ms 384 KB
s2.txt AC 6 ms 384 KB
s3.txt AC 7 ms 384 KB