Skip to content

Commit

Permalink
problem 3 MAGA - the mother fucker
Browse files Browse the repository at this point in the history
  • Loading branch information
harrypotter0 committed Jan 24, 2018
1 parent 361b400 commit 602e641
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Binary file modified CP/JanuaryCookOff2018/a.out
Binary file not shown.
22 changes: 14 additions & 8 deletions CP/JanuaryCookOff2018/prob3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ bool ok(int i)
int N;
int ans()
{
int i = (N + 1) / 2;cout<<i<<"::i's value";
int j = (N + 2) / 2;cout<<j<<"::j's value";
int i = (N + 1) / 2;
int j = (N + 2) / 2;
int id = 0;
D1[id] = N + 2;
D2[id] = N + 2;
Expand All @@ -27,12 +27,10 @@ int ans()
{
if (ok(i))
D1[id] = 0;
cout<<A[i]<<"::A[i]'s value"<<A[j]<<"::A[j]'s value";
swap(A[i], A[j]);
if (ok(i))
D2[id] = 1;
swap(A[i], A[j]);
cout<<D1[id]<<"1id"<<" "<<D2[id]<<"2id";
}
while (true)
{
Expand All @@ -44,20 +42,28 @@ int ans()
D1[id] = N + 2;
D2[id] = N + 2;
{
if (ok(i) && ok(j - 1))
if (ok(i) && ok(j - 1)){
D1[id] = min(D1[id], D1[id - 1]);
// cout<<"Value D1 "<<D1[id]<<i<<" "<<j<<endl;
}
swap(A[i + 1], A[j - 1]);
if (ok(i) && ok(j - 1))
if (ok(i) && ok(j - 1)){
D1[id] = min(D1[id], D2[id - 1]);
// cout<<"Value D1 "<<D1[id]<<i<<" "<<j<<endl;
}
swap(A[i + 1], A[j - 1]);
}
swap(A[i], A[j]);
{
if (ok(i) && ok(j - 1))
if (ok(i) && ok(j - 1)){
D2[id] = min(D2[id], 1 + D1[id - 1]);
// cout<<"Value D2 "<<D2[id]<<i<<" "<<j<<endl;
}
swap(A[i + 1], A[j - 1]);
if (ok(i) && ok(j - 1))
if (ok(i) && ok(j - 1)){
D2[id] = min(D2[id], 1 + D2[id - 1]);
// cout<<"Value D2 "<<D2[id]<<i<<" "<<j<<endl;
}
swap(A[i + 1], A[j - 1]);
}
swap(A[i], A[j]);
Expand Down

0 comments on commit 602e641

Please sign in to comment.