#include <cstdio> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <string> #include <sstream> #include <cmath> using namespace std; typedef vector<int> vi; typedef long long ll; typedef vector<ll> vll; typedef pair<int,int> pii; #define mp make_pair #define REP(i,n) for (int i=0,___=(n); i<___; ++i) #define FOR(i,a,b) for (int i=(a),___=(b); i<=___; ++i) #define FORD(i,a,b) for (int i=(a),___=(b); i>=___; --i) #define FOR2(i,a,b) for (int ___A=(a),___B=(b),___BR=1; ___BR; ___BR=0) for (i=___A; i<=___B; ++i) #include "cielib.h" const int MAXD = 500; int v[MAXD]; int query[MAXD]; void solve() { int d = podajD(); int r = podajR(); REP(i, d) v[i] = 0; int n = r; while (n > 2) { REP(i, d) query[i] = v[i] + n/2; REP(i, d) { int prevQueryI = query[i]; query[i] = v[i]; czyCieplo(query); query[i] = v[i] + n; if (czyCieplo(query)) { v[i] += n/2; } query[i] = prevQueryI; } n -= n/2; } REP(i, d) query[i] = v[i] + 1; REP(i, d) { int prevQueryI = query[i]; query[i] = v[i]; czyCieplo(query); query[i] = v[i] + 2; if (czyCieplo(query)) { v[i] += 2; } else { query[i] = v[i]; if (czyCieplo(query) == 0) { ++v[i]; } } query[i] = prevQueryI; } znalazlem(v); } int main() { solve(); 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 | #include <cstdio> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <string> #include <sstream> #include <cmath> using namespace std; typedef vector<int> vi; typedef long long ll; typedef vector<ll> vll; typedef pair<int,int> pii; #define mp make_pair #define REP(i,n) for (int i=0,___=(n); i<___; ++i) #define FOR(i,a,b) for (int i=(a),___=(b); i<=___; ++i) #define FORD(i,a,b) for (int i=(a),___=(b); i>=___; --i) #define FOR2(i,a,b) for (int ___A=(a),___B=(b),___BR=1; ___BR; ___BR=0) for (i=___A; i<=___B; ++i) #include "cielib.h" const int MAXD = 500; int v[MAXD]; int query[MAXD]; void solve() { int d = podajD(); int r = podajR(); REP(i, d) v[i] = 0; int n = r; while (n > 2) { REP(i, d) query[i] = v[i] + n/2; REP(i, d) { int prevQueryI = query[i]; query[i] = v[i]; czyCieplo(query); query[i] = v[i] + n; if (czyCieplo(query)) { v[i] += n/2; } query[i] = prevQueryI; } n -= n/2; } REP(i, d) query[i] = v[i] + 1; REP(i, d) { int prevQueryI = query[i]; query[i] = v[i]; czyCieplo(query); query[i] = v[i] + 2; if (czyCieplo(query)) { v[i] += 2; } else { query[i] = v[i]; if (czyCieplo(query) == 0) { ++v[i]; } } query[i] = prevQueryI; } znalazlem(v); } int main() { solve(); return 0; } |