結果

問題 No.206 数の積集合を求めるクエリ
ユーザー yaoshimaxyaoshimax
提出日時 2015-05-24 17:24:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5,741 ms / 7,000 ms
コード長 735 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 53,520 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 11:23:20
合計ジャッジ時間 31,150 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 42 ms
4,380 KB
testcase_13 AC 35 ms
4,376 KB
testcase_14 AC 40 ms
4,376 KB
testcase_15 AC 40 ms
4,376 KB
testcase_16 AC 39 ms
4,380 KB
testcase_17 AC 53 ms
4,376 KB
testcase_18 AC 27 ms
4,376 KB
testcase_19 AC 48 ms
4,376 KB
testcase_20 AC 27 ms
4,376 KB
testcase_21 AC 34 ms
4,376 KB
testcase_22 AC 33 ms
4,376 KB
testcase_23 AC 49 ms
4,376 KB
testcase_24 AC 3,368 ms
4,380 KB
testcase_25 AC 5,741 ms
4,376 KB
testcase_26 AC 3,787 ms
4,380 KB
testcase_27 AC 2,577 ms
4,376 KB
testcase_28 AC 4,988 ms
4,376 KB
testcase_29 AC 4,842 ms
4,380 KB
testcase_30 AC 3,326 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int main(){
   int L,M,N;
   cin >> L >> M >> N;
   int A[L],B[M];
   int X[3500]={0};
   int Y[3500]={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 < 3500; 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 < 3500; j++){
         Y[j]<<=1;
         Y[j]+=carry;
         carry=Y[j]/(1<<30);
         Y[j]%=(1<<30);
      }
   }
   return 0;
}
0