Submission

Status:
[P][P][P][TS][PT][PT][PT][PT][PT][PT]

Score: 30

User: hmmm

Problemset: ตัดกระดาษ

Language: cpp

Time: 1.092 second

Submitted On: 2025-04-18 14:49:48

#include<bits/stdc++.h>
using namespace std;
const int N=1e5;
int mp2[N+5];
unordered_map<int,int> mp;
vector<int> p;

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
  int l,w,n,m,q;
  cin >> l >> w >> n >> m >> q;
  int t,x;
  cin >> t;
  // p.push_back(t);
  if(t<=N) mp[t]++;
  for(int i=2;i<=n;i++){
    cin >> x;
    if(x-t<=N) mp[x-t]++;
    // p.push_back(x-t);
    t=x;
  }
  if(l-x<=N) mp[l-x]++;
  // p.push_back(n-t);
  t=0;
  for(int i=1;i<=m;i++){
    cin >> x;
    for(auto e:mp){
      if(1ll*(x-t)*e.first<=N) mp2[(x-t)*e.first]+=e.second;
    }
    t=x;
  }
  for(auto e:mp){
    if(1ll*(w-x)*e.first<=N) mp2[(w-x)*e.first]+=e.second;
  }
  while(q--){
    cin >> x;
    cout << mp2[x] << "\n";
  }
}