# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
247237 | 2020-07-11T08:19:25 Z | dantoh000 | Lokahian Relics (FXCUP4_lokahia) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; //#include "lokahia.h" int Q[205][205]; int query(int i, int j){ if (i == j) return Q[i][i] = i; else if (Q[i][j] == -2) return Q[i][j] = Q[j][i] = CollectRelics(i,j); else return Q[i][j]; } int FindBase(int N){ for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) Q[i][j] = -2; vector<int> pos; int cur = 0; for (int i = 0; i < N; i++){ if (cur == i) continue; int q = query(cur,i); if (q != -1 && q > cur) cur = q; } int ct = 0; for (int i = 0; i < N; i++){ if (i == cur || query(i,cur) != -1) ct++; if (ct > N/2) break; } if (ct > N/2) return cur; else return -1; }