結果
| 問題 | 
                            No.8016 unordered_mapなるたけ落とすマン
                             | 
                    
| ユーザー | 
                             | 
                    
| 提出日時 | 2017-12-14 22:12:32 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 118 ms / 1,000 ms | 
| コード長 | 447 bytes | 
| コンパイル時間 | 601 ms | 
| コンパイル使用メモリ | 51,712 KB | 
| 最終ジャッジ日時 | 2025-01-05 05:27:27 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 48 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |   scanf("%d%d", &n, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~
main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |     scanf("%lld", &x);
      |     ~~~~~^~~~~~~~~~~~
main.cpp:18:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |     scanf("%lld", &x);
      |     ~~~~~^~~~~~~~~~~~
            
            ソースコード
#include <cstdio>
#include <map>
using int64 = long long;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  std::map<int64, int> cnt;
  for (int i = 0; i < n; ++i) {
    int64 x;
    scanf("%lld", &x);
    ++cnt[x];
  }
  for (int i = 0; i < m; ++i) {
    if (i) putchar(' ');
    int64 x;
    scanf("%lld", &x);
    auto it = cnt.find(x);
    if (it == cnt.end()) putchar('0');
    else printf("%d", it->second);
  }
  puts("");
  return 0;
}