#include using namespace std; //const int BIG_PRIME = 999983; const int MAXN=200000000; const int MAXR=7000000; int N,M,B,gi=0,gr=0; struct t_res { int prev, id, off; }; vector many_nums; vector many_res; typedef long long ll; int best_val = -1; int best_off = -1; int main() { double t = clock(); ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef LOCAL freopen("subsetselection.in", "r", stdin); freopen("subsetselection.out", "w", stdout); #endif srand(123456789); cin>>N>>M>>B; // PUSH IT TO THE LIMIT int max_bytes = 250*1024*1024; int max_many = max_bytes/(M+12); many_nums.resize(max_many*M+2); many_res.resize(max_many+2); for(int n=0;n>temp; many_nums[gi]=temp%B; gi++; } many_res[n].prev=-1; many_res[n].id= n+1; many_res[n].off = n*M; } gr = N; random_shuffle(many_res.begin(),many_res.begin()+N); for(int n=0;nbest_val) { best_val = val; best_off = n; } } /* auto hash = [&](const int& a){ int oa = many_res[a].off; ll hash = 0; for(int m=0;m seen(BIG_PRIME,hash,equal); */ int try_count = N; for(int i=0;i=0 && gr 4.85) goto gg; bool gotyou=false; int cur = j; while(cur>=0) { if(many_res[cur].id == many_res[i].id) { gotyou=true; break; } cur = many_res[cur].prev; } if(gotyou)continue; int oa = many_res[i].off, ob = many_res[j].off; int val = 0,temp; for(int m=0;mbest_val) { best_val = val; best_off = gr; } gr++; gi+=M; //} try_count++; } } //cout<<"TIME OK BRO "< chosen; int cur_off = best_off; do { chosen.push_back(many_res[cur_off].id); cur_off = many_res[cur_off].prev; } while(cur_off!=-1); sort(chosen.begin(),chosen.end()); //chosen.erase(unique(chosen.begin(),chosen.end()),chosen.end()); cout<