#include using namespace std; using ll = long long; #define chmax(a,b) a = max(a,b) pair calc(int a,int b){ return make_pair(min(a,b),max(a,b)); } int main(){ int n,k,x,y; cin>>n>>k>>x>>y; vector a(n); for(int i = 0;i>a[i]; map,int> d; vector b(n+2); x %= k; y %= k; b[0] = x % k; b[1] = y % k; for(int i = 0;i>>s; d[make_pair(min(x,y),max(x,y))] = 0; s[(x+y)%k].insert(make_pair(min(x,y),max(x,y))); int ans = 0; vector tmp(n+2,0); for(int i = 0;i>>use; for(auto itr:s[need]){ int aa = itr.first; int bb = itr.second; int can = d[itr]; ans = max(ans,can+1); use.push_back(make_pair(can+1,calc(aa,now))); use.push_back(make_pair(can+1,calc(bb,now))); chmax(tmp[i+2],can+1); //cout<