304C - Lucky Permutation Triple - CodeForces Solution


constructive algorithms *1300

Please click on ads to support us..

Python Code:

n = int(input())
if n % 2 == 0:
    print(-1)
else:
    for _ in range(2):
        print(*range(0, n))
    for i in range(0, n, 2):
        print(i, end=" ")
    for i in range(1, n, 2):
        print(i, end=" ")

C++ Code:

#include <iostream>
#include <vector>
using namespace std;

int main(){
    int n; cin >> n;
    if(n%2 == 0){
        cout << -1; return 0;
    }
    vector <int> v1,v2,v3;
    for (size_t i = 0; i < n; i++)
    {
        v1.push_back(i);
        v2.push_back(i);
    }
    for (size_t i = 0; i < n; i++)
    {
        v3.push_back((v1[i]+v2[i])%n);
    }
    for(auto i: v1) cout << i << " ";
    cout << "\n";
    for(auto i: v2) cout << i << " ";
    cout << "\n";
    for(auto i: v3) cout << i << " ";
    cout << "\n";
    return 0;
}


Comments

Submit
0 Comments
More Questions

2B - The least round way
1324A - Yet Another Tetris Problem
246B - Increase and Decrease
22E - Scheme
1566A - Median Maximization
1278A - Shuffle Hashing
1666F - Fancy Stack
1354A - Alarm Clock
1543B - Customising the Track
1337A - Ichihime and Triangle
1366A - Shovels and Swords
919A - Supermarket
630C - Lucky Numbers
1208B - Uniqueness
1384A - Common Prefixes
371A - K-Periodic Array
1542A - Odd Set
1567B - MEXor Mixup
669A - Little Artem and Presents
691B - s-palindrome
851A - Arpa and a research in Mexican wave
811A - Vladik and Courtesy
1006B - Polycarp's Practice
1422A - Fence
21D - Traveling Graph
1559B - Mocha and Red and Blue
1579C - Ticks
268B - Buttons
898A - Rounding
1372B - Omkar and Last Class of Math