結果

問題 No.182 新規性の虜
コンテスト
ユーザー zxc
提出日時 2016-01-18 06:07:36
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 712 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 938 ms
コンパイル使用メモリ 93,584 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-04-08 08:54:19
合計ジャッジ時間 31,549 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 TLE * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:20:14: warning: ignoring return value of '_FIter std::unique(_FIter, _FIter) [with _FIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]', declared with attribute 'nodiscard' [-Wunused-result]
   20 |   std::unique( std::begin(vc2), std::end(vc2) );
      |   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:63,
                 from main.cpp:3:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algo.h:875:5: note: declared here
  875 |     unique(_ForwardIterator __first, _ForwardIterator __last)
      |     ^~~~~~

ソースコード

diff #
raw source code

#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>

int main(){
  std::cout.sync_with_stdio(false);
  std::vector<int> vc;
  size_t N;
  std::cin >> N;
  vc.resize(N);
  for(auto& elm: vc ){
        std::cin>> elm;
  }
  std::vector<int> vc2;
  const int dead_value(0);
  vc2.resize(vc.size(),dead_value);
  std::sort( std::begin(vc), std::end(vc));
  std::unique_copy(std::begin(vc),std::end(vc),std::begin(vc2) );
  std::unique( std::begin(vc2), std::end(vc2) );
  size_t cnt{0};
  for(const auto& elm:vc2){
     if(elm == 0)break;
     if(1==count_if( std::begin(vc), std::end(vc) ,[=](const int i)->bool{return i==elm;})){
        cnt++;
     }
  }
  std::cout<<cnt<<std::endl;

}
0