#include <cstdio> #include <vector> #include <numeric> #include <algorithm> #include "sonlib.h" bool explore0(int from, int to) { if (MoveProbe(to) == 0) return false; MoveProbe(from); return true; } int n; int p[401]; int get_other() { std::iota(p, p+(n-1), 2); int cnt = 0; while (true) { std::random_shuffle(p, p+(n-1)); for (int i = 0; i < n-1; i++) { if (MoveProbe(p[i]) == 1) return p[i]; } MoveProbe(1); cnt += n; if (cnt > 900000) return -1; } } int main() { n = GetN(); if (GetSubtask() != 1) { printf("lubię placki\n"); return 0; } Examine(); int k = get_other(); //printf("k = %d\n", k); if (k == -1) { for (int i = 2; i <= n; i++) { MoveProbe(i); Examine(); MoveProbe(1); } } else { std::vector<int> white; for (int i = 2; i <= n; i++) { if (i == k) continue; MoveProbe(i); if (MoveProbe(1) == 1) { white.push_back(i); MoveProbe(i); Examine(); MoveProbe(k); } } MoveProbe(white[0]); for (int i = 2; i <= n; i++) { if (i == white[0]) continue; if (MoveProbe(i) == 1) { Examine(); MoveProbe(white[0]); } } } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | #include <cstdio> #include <vector> #include <numeric> #include <algorithm> #include "sonlib.h" bool explore0(int from, int to) { if (MoveProbe(to) == 0) return false; MoveProbe(from); return true; } int n; int p[401]; int get_other() { std::iota(p, p+(n-1), 2); int cnt = 0; while (true) { std::random_shuffle(p, p+(n-1)); for (int i = 0; i < n-1; i++) { if (MoveProbe(p[i]) == 1) return p[i]; } MoveProbe(1); cnt += n; if (cnt > 900000) return -1; } } int main() { n = GetN(); if (GetSubtask() != 1) { printf("lubię placki\n"); return 0; } Examine(); int k = get_other(); //printf("k = %d\n", k); if (k == -1) { for (int i = 2; i <= n; i++) { MoveProbe(i); Examine(); MoveProbe(1); } } else { std::vector<int> white; for (int i = 2; i <= n; i++) { if (i == k) continue; MoveProbe(i); if (MoveProbe(1) == 1) { white.push_back(i); MoveProbe(i); Examine(); MoveProbe(k); } } MoveProbe(white[0]); for (int i = 2; i <= n; i++) { if (i == white[0]) continue; if (MoveProbe(i) == 1) { Examine(); MoveProbe(white[0]); } } } } |