結果

問題 No.206 数の積集合を求めるクエリ
ユーザー yaoshimax
提出日時 2015-05-24 17:12:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 705 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 55,376 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 06:47:49
合計ジャッジ時間 3,395 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 6 RE * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int main(){
   int L,M,N;
   cin >> L >> M >> N;
   int A[L],B[M];
   int X[350]={0};
   int Y[350]={0};
   for(int i=0;i<L;i++){
      cin>>A[i];
      X[A[i]/30]|=1<<(A[i]%30);
   }
   for(int i=0;i<M;i++){
      cin>>B[i];
      Y[B[i]/30]|=1<<(B[i]%30);
   }
   int Q;
   cin >> Q;
   for( int i = 0 ; i<Q; i++){
      int ans =0;
      for( int j = 0 ; j < 350; j++){
         int c=(X[j]&Y[j]);
         while(c!=0){
            ans++;
            c&=(c-1);
         }
      }
      cout <<ans << endl;
      int carry = 0;
      for( int j = 0 ; j < 350; j++){
         Y[j]<<=1;
         Y[j]+=carry;
         carry=(Y[j]>>30);
      }
   }
   return 0;
}
0