結果

問題 No.206 数の積集合を求めるクエリ
ユーザー angel_p_57angel_p_57
提出日時 2015-05-12 12:24:15
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 733 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 27,260 KB
実行使用メモリ 7,908 KB
最終ジャッジ日時 2023-09-20 03:48:38
合計ジャッジ時間 9,721 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 11 ms
4,380 KB
testcase_07 AC 12 ms
4,376 KB
testcase_08 AC 17 ms
4,376 KB
testcase_09 AC 17 ms
4,376 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 40 ms
4,384 KB
testcase_13 AC 13 ms
4,380 KB
testcase_14 AC 18 ms
4,384 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cassert>
#include <cstdlib>

using namespace std;

int main(void)
{
  // input
  int L,M,N,Q,ret;
  ret=scanf("%d%d%d",&L,&M,&N);
  assert(ret==3&&L>0&&M>0&&N>0&&L<=N&&M<=N);

  int *abp = (int*)malloc(sizeof(int)*(L+M));
  assert(abp);

  for ( int i=0; i<L+M; i++ )
  {
    int *tp=&abp[i];
    ret=scanf("%d",tp);
    assert(ret&&*tp>=1&&*tp<=N);
  }
  int *A=&abp[0], *B=&abp[L];

  ret=scanf("%d",&Q);
  assert(ret&&Q>=1&&Q<=N);

  // solve
  int *R = (int*)calloc(Q,sizeof(int));
  assert(R);
  for ( int i=0; i<L; i++ )
    for ( int j=0; j<M; j++ )
    {
      int v=A[i]-B[j];
      if ( v>=0 && v<Q ) R[v]++;
    }

  // result
  for ( int i=0; i<Q; i++ )
    printf("%d\n",R[i]);

  return 0;
}
0