#include #include #include #include #include #include #include #include #include using namespace std; mt19937 rnd(22); const int MAXN = 1e5; int n, k, s, w, z, startX, startY; int p[MAXN*2]; vector >* blackHoles[MAXN+5]; void readAndInit() { #ifndef _LOCAL_ ifstream cin("cleanUP.in"); ofstream cout("cleanUP.out"); #endif cin >> n >> k >> s >> w >> z >> startX >> startY; for(int i = 0;i<=(int)floor((n-1)*sqrt(2)+0.0001);i++) cin >> p[i]; vector > *currHoles = new vector>(); for(int i = 0;i> a >> b; currHoles->emplace_back(a, b); } int period = floor(sqrt(s)); for(int i = 0;i> *newHoles = new vector >(k); for(int j = 0;j movePos(pair pos, char c) { if(c=='L') pos.second--; else if(c=='R') pos.second++; else if(c=='U') pos.first--; else if(c=='D') pos.first++; else assert(false); return pos; } bool isInside(pair pos) { return ((1<=pos.first && pos.first<=n) && (1<=pos.second && pos.second<=n)); } int64_t eval(const string& s) { pair curr = {startX, startY}; set > used = {curr}; int64_t score = getScore(curr.first, curr.second, 0); for(int second = 0;second& s) { pair curr = {startX, startY}; set > used = {curr}; int64_t score = getScore(curr.first, curr.second, 0); for(int second = 0;second &v) { char moves[] = {'L', 'R', 'U', 'D'}; pair pos = {startX, startY}; for(int i = 0;i newPos = movePos(pos, moves[j]); if(isInside(newPos)==true) { v[i] = moves[j]; pos = newPos; break; } } } } int main() { #ifndef _LOCAL_ ifstream cin("cleanUP.in"); ofstream cout("cleanUP.out"); #endif readAndInit(); vector ans; int64_t bestAnsScore = -100; vector test(s); double startTime = clock(); while((clock()-startTime)/CLOCKS_PER_SEC<4.6) { genRandom(test); int64_t score = eval(test); if(score>bestAnsScore) { bestAnsScore = score; ans = test; } } for(int i = 0;i