#include "cielib.h"
//#include "cielib.c"
#include<bits/stdc++.h>
using namespace std;
int d;
typedef vector<int> VI;
void print(VI& t)
{
for(int i=0;i<d;++i)
printf("%d ",t[i]);
printf("\n");
}
VI operator +(VI& t,VI& u)
{
VI w(d);
for(int i=0;i<d;++i)
w[i]=t[i]+u[i];
return w;
}
VI operator +(VI& t,int k)
{
VI w(d);
for(int i=0;i<d;++i)
w[i]=t[i]+k;
return w;
}
void kostka(VI& l,int& r)
{
VI t=l+r/2;
bool bb;
for(int i=0;i<d;++i)
{
t[i]=l[i];
// print(t);
czyCieplo(&t[0]);
t[i]=l[i]+r;
// print(t);
// printf("%d\n",bb=czyCieplo(&t[0]));
bb=czyCieplo(&t[0]);
t[i]=l[i]+r/2;
if(bb)
l[i]+=r/2;
}
r-=r/2;
}
void kostka2(VI& l)
{
VI t=l+1;
bool b1,b2;
for(int i=0;i<d;++i)
{
t[i]=l[i];
czyCieplo(&t[0]);
t[i]+=2;
b1=czyCieplo(&t[0]);
t[i]-=2;
b2=czyCieplo(&t[0]);
if(b1)
l[i]+=2;
else if(!b2)
l[i]++;
t[i]++;
}
// print(l);
znalazlem(&l[0]);
}
int main()
{
d=podajD();
int r(podajR());
VI t(d);
while(r>2)
kostka(t,r);
// print(t);
kostka2(t);
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 | #include "cielib.h" //#include "cielib.c" #include<bits/stdc++.h> using namespace std; int d; typedef vector<int> VI; void print(VI& t) { for(int i=0;i<d;++i) printf("%d ",t[i]); printf("\n"); } VI operator +(VI& t,VI& u) { VI w(d); for(int i=0;i<d;++i) w[i]=t[i]+u[i]; return w; } VI operator +(VI& t,int k) { VI w(d); for(int i=0;i<d;++i) w[i]=t[i]+k; return w; } void kostka(VI& l,int& r) { VI t=l+r/2; bool bb; for(int i=0;i<d;++i) { t[i]=l[i]; // print(t); czyCieplo(&t[0]); t[i]=l[i]+r; // print(t); // printf("%d\n",bb=czyCieplo(&t[0])); bb=czyCieplo(&t[0]); t[i]=l[i]+r/2; if(bb) l[i]+=r/2; } r-=r/2; } void kostka2(VI& l) { VI t=l+1; bool b1,b2; for(int i=0;i<d;++i) { t[i]=l[i]; czyCieplo(&t[0]); t[i]+=2; b1=czyCieplo(&t[0]); t[i]-=2; b2=czyCieplo(&t[0]); if(b1) l[i]+=2; else if(!b2) l[i]++; t[i]++; } // print(l); znalazlem(&l[0]); } int main() { d=podajD(); int r(podajR()); VI t(d); while(r>2) kostka(t,r); // print(t); kostka2(t); return 0; } |
English