#include "cielib.h" #include <bits/stdc++.h> using namespace std; #define REP(i,a,b) for (int i = (a); i <= (b); ++i) #define REPD(i,a,b) for (int i = (a); i >= (b); --i) #define FORI(i,n) REP(i,1,n) #define FOR(i,n) REP(i,0,int(n)-1) #define mp make_pair #define pb push_back #define pii pair<int,int> #define vi vector<int> #define ll long long #define SZ(x) int((x).size()) #define DBG(v) cerr << #v << " = " << (v) << endl; #define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) #define fi first #define se second const int D = 555; int d,r,k,mid; int base[D], res[D], question[D], fin[D]; int ask(int p) { if (fin[p]) return 0; FOR(i,d) question[i] = base[i] + mid; question[p] = base[p]; czyCieplo(question); question[p] = base[p] + r; int res1 = czyCieplo(question); question[p] = base[p]; int res2 = czyCieplo(question); if (res1==0 && res2==0) return 0; if (res1) return 1; return -1; } int main() { d = podajD(); r = podajR(); k = podajK(); while (r>2) { //printf("loop: r=%d, base=", r); //FOR(i,d) printf("%d ", base[i]); printf("\n"); fflush(stdout); mid = r/2; FOR(i,d) { res[i] = ask(i); } if (r%2==0) { FOR(i,d) if (!fin[i]) { if (res[i]==0) { base[i] += mid; fin[i] = 1; } if (res[i]==1) { base[i] += mid; } } } else { FOR(i,d) if (!fin[i]) { if (res[i]==0) { base[i] += mid; } if (res[i]==1) { base[i] += mid+1; } } } r /= 2; } if (r==1) { FOR(i,d) if (base[i]>0) base[i]--; } r=2; mid=1; FOR(i,d) { res[i]=ask(i); } FOR(i,d) { if (res[i] == 0) base[i]++; if (res[i] == 1) base[i]+=2; } znalazlem(base); return 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 75 76 77 78 79 80 81 82 83 84 85 86 | #include "cielib.h" #include <bits/stdc++.h> using namespace std; #define REP(i,a,b) for (int i = (a); i <= (b); ++i) #define REPD(i,a,b) for (int i = (a); i >= (b); --i) #define FORI(i,n) REP(i,1,n) #define FOR(i,n) REP(i,0,int(n)-1) #define mp make_pair #define pb push_back #define pii pair<int,int> #define vi vector<int> #define ll long long #define SZ(x) int((x).size()) #define DBG(v) cerr << #v << " = " << (v) << endl; #define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) #define fi first #define se second const int D = 555; int d,r,k,mid; int base[D], res[D], question[D], fin[D]; int ask(int p) { if (fin[p]) return 0; FOR(i,d) question[i] = base[i] + mid; question[p] = base[p]; czyCieplo(question); question[p] = base[p] + r; int res1 = czyCieplo(question); question[p] = base[p]; int res2 = czyCieplo(question); if (res1==0 && res2==0) return 0; if (res1) return 1; return -1; } int main() { d = podajD(); r = podajR(); k = podajK(); while (r>2) { //printf("loop: r=%d, base=", r); //FOR(i,d) printf("%d ", base[i]); printf("\n"); fflush(stdout); mid = r/2; FOR(i,d) { res[i] = ask(i); } if (r%2==0) { FOR(i,d) if (!fin[i]) { if (res[i]==0) { base[i] += mid; fin[i] = 1; } if (res[i]==1) { base[i] += mid; } } } else { FOR(i,d) if (!fin[i]) { if (res[i]==0) { base[i] += mid; } if (res[i]==1) { base[i] += mid+1; } } } r /= 2; } if (r==1) { FOR(i,d) if (base[i]>0) base[i]--; } r=2; mid=1; FOR(i,d) { res[i]=ask(i); } FOR(i,d) { if (res[i] == 0) base[i]++; if (res[i] == 1) base[i]+=2; } znalazlem(base); return 0; } |