http://codeforces.com/problemset/problem/303/A
- when n is odd, A[i] = B[i] = i
- when n is even, there is no solution.
- why? If , then or just , where S = 0 + 1 + ... + n - 1 = n(n - 1) / 2. So, there must be . But when n is even, .
/*92ms,0KB*/
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
if (n & 1)
{
for (int i = 0; i < n; i++) cout << i << " ";
cout << endl;
for (int i = 0; i < n; i++) cout << i << " ";
cout << endl;
for (int i = 0; i < n; i++) cout << (2 * i) % n << " ";
cout << endl;
}
else cout << -1 << endl;
return 0;
}