Submission #71953

#TimeUsernameProblemLanguageResultExecution timeMemory
71953고윤하 연말콘 언제하니 (#119)Get Hundred Points! (FXCUP3_hundred)Text
0 / 100
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; bool isp[10004], g[104][104]; int deg[104]; default_random_engine re(20000901); int mxk, k, u[104], ans[104]; bool run() { if (k > mxk) { cout << k << ": "; for (int i=0; i<k; i++) cout << ans[i] << ' '; cout << '\n'; mxk = k; } if (k==100) return true; vector<int> w; for (int i=1; i<=100; i++) if (!u[i]) if (!k or g[ans[k-1]][i]) w.push_back(i); if (w.empty()) return false; shuffle(w.begin(), w.end(), re); for (int i : w) { u[i] = 1, ans[k++] = i; if (run()) return true; else u[i] = 0, k--; } return false; } int main() { cout << 90 << '\n'; cout << "63 66 55 18 49 72 44 30 85 96 36 5 42 31 90 13 84 9 54 7 4 39 48 45 26 17 80 57 74 83 24 47 38 50 2 23 20 59 32 65 8 12 61 70 67 46 73 6 81 100 99 88 15 98 60 22 16 78 25 28 1 82 19 10 27 76 58 79 34 33 64 87 94 3 14 75 62 51 56 53 92 35 86 41 68 21 52 43 40 37"; return 0; int seed; cin >> seed; re = default_random_engine(seed); fill(isp+2, isp+10004, true); for (int i=2; i<10004; i++) if (isp[i]) for (int j=i; i*j<10004; j++) isp[i*j] = false; for (int i=1; i<=100; i++) for (int j=1; j<=100; j++) if (i!=j) { if (isp[i*j+1]) g[i][j] = true, deg[i]++; } run(); for (int i=0; i<100; i++) cout << ans[i]; }
#Verdict Execution timeMemoryGrader output
Fetching results...