結果

問題 No.182 新規性の虜
ユーザー Eclair1015
提出日時 2018-08-21 03:28:54
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 402 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 65,440 KB
実行使用メモリ 394,240 KB
最終ジャッジ日時 2024-11-29 00:25:08
合計ジャッジ時間 104,194 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:35: warning: iteration 100000010 invokes undefined behavior [-Waggressive-loop-optimizations]
   20 |         rep(i, 1000000001) if (b[i] == 1) cnt++;
      |                                ~~~^
main.cpp:8:36: note: within this loop
    8 | #define rep(i, n) for(int i = 0; i < (int)(n); i++)
      |                                    ^
main.cpp:20:9: note: in expansion of macro ‘rep’
   20 |         rep(i, 1000000001) if (b[i] == 1) cnt++;
      |         ^~~

ソースコード

diff #

#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int b[100000010] = {};
	rep(i, n) cin >> a[i];

	rep(i, n) b[a[i]]++;
	int cnt = 0;
	rep(i, 1000000001) if (b[i] == 1) cnt++;
	cout << cnt << endl;
	return 0;
}
0