Submission #7447315


Source Code Expand

#include <cstdio>
#include <cstdint>
#include <random>
#include <iostream>
#include <list>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>

template <typename ForwardIt>
void my_merge(ForwardIt first, ForwardIt mid, ForwardIt last) {
  using value_type = typename std::iterator_traits<ForwardIt>::value_type;
  std::vector<value_type> left(std::make_move_iterator(first), std::make_move_iterator(mid));
  std::vector<value_type> right(std::make_move_iterator(mid), std::make_move_iterator(last));
  auto itl = left.begin();
  auto itr = right.begin();
  while (first != last) {
    bool from_left = !(itl == left.end() || (itr != right.end() && *itr < *itl));
    *first++ = std::move(*(from_left? itl: itr));
    ++(from_left? itl: itr);
  }
}

template <typename ForwardIt>
void my_sort(ForwardIt first, ForwardIt last) {
  if (first == last) return;

  using difference_type = typename std::iterator_traits<ForwardIt>::difference_type;
  auto next_until = [](ForwardIt it, difference_type n, ForwardIt sent) {
    while (n-- && it != sent) ++it;
    return it;
  };
  for (difference_type width = 1; true; width <<= 1) {
    auto first0 = first;
    while (first0 != last) {
      auto mid0 = next_until(first0, width, last);
      auto last0 = next_until(mid0, width, last);
      if (mid0 == last0) {
        if (first == first0) return;
        break;
      }
      my_merge(first0, mid0, last0);
      first0 = last0;
    }
  }
}

int main() {
  size_t n;
  scanf("%zu", &n);

  std::list<int> a(n);
  for (auto& ai: a) {
    scanf("%d", &ai);
    ai >>= __builtin_ctz(ai);
  }

  my_sort(a.begin(), a.end());
  a.erase(std::unique(a.begin(), a.end()), a.end());
  printf("%zu\n", a.size());
}

Submission Info

Submission Time
Task C - 高橋くんと魔法の箱
User rsk0315
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1792 Byte
Status AC
Exec Time 42 ms
Memory 3708 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:51:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%zu", &n);
                   ^
./Main.cpp:55:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &ai);
                     ^

Judge Result

Set Name Sample Subtask1 Subtask2 All
Score / Max Score 0 / 0 20 / 20 30 / 30 50 / 50
Status
AC × 3
AC × 23
AC × 13
AC × 43
Set Name Test Cases
Sample subtask0_0.txt, subtask0_1.txt, subtask0_2.txt
Subtask1 subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt, subtask0_0.txt, subtask0_1.txt, subtask0_2.txt
Subtask2 subtask2_0.txt, subtask2_1.txt, subtask2_2.txt, subtask2_3.txt, subtask2_4.txt, subtask2_5.txt, subtask2_6.txt, subtask2_7.txt, subtask2_8.txt, subtask2_9.txt, subtask0_0.txt, subtask0_1.txt, subtask0_2.txt
All subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt, subtask2_0.txt, subtask2_1.txt, subtask2_2.txt, subtask2_3.txt, subtask2_4.txt, subtask2_5.txt, subtask2_6.txt, subtask2_7.txt, subtask2_8.txt, subtask2_9.txt, subtask3_0.txt, subtask3_1.txt, subtask3_2.txt, subtask3_3.txt, subtask3_4.txt, subtask3_5.txt, subtask3_6.txt, subtask3_7.txt, subtask3_8.txt, subtask3_9.txt
Case Name Status Exec Time Memory
subtask0_0.txt AC 1 ms 256 KiB
subtask0_1.txt AC 1 ms 256 KiB
subtask0_2.txt AC 1 ms 256 KiB
subtask1_0.txt AC 2 ms 384 KiB
subtask1_1.txt AC 2 ms 384 KiB
subtask1_10.txt AC 2 ms 384 KiB
subtask1_11.txt AC 2 ms 384 KiB
subtask1_12.txt AC 2 ms 384 KiB
subtask1_13.txt AC 2 ms 384 KiB
subtask1_14.txt AC 2 ms 384 KiB
subtask1_15.txt AC 2 ms 384 KiB
subtask1_16.txt AC 2 ms 384 KiB
subtask1_17.txt AC 2 ms 384 KiB
subtask1_18.txt AC 2 ms 384 KiB
subtask1_19.txt AC 2 ms 384 KiB
subtask1_2.txt AC 2 ms 384 KiB
subtask1_3.txt AC 2 ms 384 KiB
subtask1_4.txt AC 2 ms 384 KiB
subtask1_5.txt AC 2 ms 384 KiB
subtask1_6.txt AC 2 ms 384 KiB
subtask1_7.txt AC 2 ms 384 KiB
subtask1_8.txt AC 2 ms 384 KiB
subtask1_9.txt AC 2 ms 384 KiB
subtask2_0.txt AC 34 ms 3708 KiB
subtask2_1.txt AC 41 ms 3708 KiB
subtask2_2.txt AC 41 ms 3708 KiB
subtask2_3.txt AC 41 ms 3708 KiB
subtask2_4.txt AC 41 ms 3708 KiB
subtask2_5.txt AC 41 ms 3708 KiB
subtask2_6.txt AC 41 ms 3708 KiB
subtask2_7.txt AC 41 ms 3708 KiB
subtask2_8.txt AC 41 ms 3708 KiB
subtask2_9.txt AC 41 ms 3708 KiB
subtask3_0.txt AC 34 ms 3708 KiB
subtask3_1.txt AC 42 ms 3708 KiB
subtask3_2.txt AC 42 ms 3708 KiB
subtask3_3.txt AC 42 ms 3708 KiB
subtask3_4.txt AC 42 ms 3708 KiB
subtask3_5.txt AC 42 ms 3708 KiB
subtask3_6.txt AC 42 ms 3708 KiB
subtask3_7.txt AC 42 ms 3708 KiB
subtask3_8.txt AC 42 ms 3708 KiB
subtask3_9.txt AC 42 ms 3708 KiB