text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
set<int> Set;
int n, k, a, b, c, d, i;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
cin >> a >> b >> c >> d;
if ((n == 4) || (n >= k)) {
cout << "-1" << '\n';
return 0;
}
for (i = 1; i <= n; i++) Set.insert(i);
Set.erase(a);
Set.erase(b);
Set.erase(c);
Set.erase(d);
cout << a << " " << c << " ";
for (i = 1; i <= n - 4; i++) {
cout << *Set.begin() << " ";
Set.erase(Set.begin());
}
cout << d << " " << b << '\n';
for (i = 1; i <= n; i++) Set.insert(i);
Set.erase(a);
Set.erase(b);
Set.erase(c);
Set.erase(d);
cout << c << " " << a << " ";
for (i = 1; i <= n - 4; i++) {
cout << *Set.begin() << " ";
Set.erase(Set.begin());
}
cout << b << " " << d << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
bool vis[N];
int ret[N];
int main() {
int n, k, a, b, c, d;
scanf("%d%d%d%d%d%d", &n, &k, &a, &b, &c, &d);
if (n >= 5 && k >= n + 1) {
int pos = 1;
vis[a] = vis[b] = vis[c] = vis[d] = 1;
ret[1] = a, ret[2] = c, ret[n - 1] = d, ret[n] = b;
for (int i = 3; i <= n - 2; ++i) {
while (vis[pos]) {
++pos;
}
vis[pos] = 1;
ret[i] = pos;
}
for (int i = 1; i <= n; ++i) printf("%d ", ret[i]);
swap(ret[1], ret[2]);
swap(ret[n - 1], ret[n]);
cout << endl;
for (int i = 1; i <= n; ++i) printf("%d ", ret[i]);
cout << endl;
} else {
printf("-1\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long double pi = acos(-1);
long long QPow(long long a, long long b) {
long long ans = 1;
while (b) {
if (b & 1) ans *= a;
a = a * a;
b >>= 1;
}
return ans;
}
int arr[1002];
int ans[1002];
signed main() {
ifstream in("Text.txt");
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
long long n, m;
long long k;
int a, b, c, d;
int t;
cin >> n >> m;
cin >> a >> b >> c >> d;
if (n + 1 > m || n < 5) {
cout << -1 << endl;
} else {
int cnt = 0;
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) ans[cnt++] = i;
cout << a << " " << c << " ";
for (int i = 0; i < cnt; i++) cout << ans[i] << " ";
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (int i = cnt - 1; i >= 0; i--) cout << ans[i] << " ";
cout << b << " " << d << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool is[10000];
int ans[10000], ans1[10000];
int main() {
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
if (k < n + 1 || n == 4) {
cout << -1 << endl;
return 0;
}
ans[0] = a;
ans[1] = c;
ans[n - 2] = d;
ans[n - 1] = b;
is[a] = is[b] = is[c] = is[d] = 1;
int j = 1;
for (int i = 2; i < n - 2; i++) {
for (j; j <= n; j++) {
if (is[j]) continue;
ans[i] = j;
j++;
break;
}
}
for (int i = 0; i < n; i++) cout << ans[i] << " ";
cout << endl;
swap(ans[0], ans[1]);
swap(ans[n - 1], ans[n - 2]);
for (int i = 0; i < n; i++) {
cout << ans[i] << " ";
}
cout << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<long long int> adj[1000];
void solve() {
long long int n, k, a, b, c, d, p, cnt, id;
cin >> n >> k >> a >> b >> c >> d;
if (k < (n + 1)) {
cout << -1;
return;
}
vector<long long int> p1, p2;
p1.push_back(a);
p1.push_back(c);
k--;
for (long long int i = 1; i < n + 1; i++) {
if (i == a || i == c || i == b || (p1.size() == 2 && i == d)) continue;
p1.push_back(i);
if (i == d) id = p1.size() - 1;
k--;
}
if (p1.back() != c && p1.size() == (n - 2)) {
p1.push_back(d);
k--;
id = p1.size() - 1;
}
p1.push_back(b);
k--;
if (p1.size() != n || k < 0) {
cout << -1;
return;
}
for (long long int i = 0; i < p1.size(); i++) cout << p1[i] << " ";
cout << endl;
cout << c << " " << a << " ";
for (long long int i = 2; i < id; i++) {
cout << p1[i] << " ";
}
for (long long int i = n - 1; i >= id; i--) cout << p1[i] << " ";
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long int t;
t = 1;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n, k, a, b, c, d;
int main() {
scanf("%d %d %d %d %d %d", &n, &k, &a, &b, &c, &d);
if (n == 4 || n >= k) {
printf("-1\n");
return 0;
}
printf("%d %d ", a, c);
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) {
printf("%d ", i);
}
}
printf("%d %d\n%d %d ", d, b, c, a);
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) {
printf("%d ", i);
}
}
printf("%d %d\n", b, d);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, a, b, c, d;
scanf("%d%d%d%d%d%d", &n, &k, &a, &b, &c, &d);
if (k < n + 1 || n == 4)
printf("-1\n");
else {
printf("%d %d ", a, c);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d %d\n", d, b);
printf("%d %d ", c, a);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d %d\n", b, d);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 1;
const int MOD = 1e9 + 7;
int N, K;
int a, b, c, d;
int main() {
std::ios::sync_with_stdio(false);
std::cin >> N >> K;
std::cin >> a >> b >> c >> d;
if (K <= N || N == 4) {
return puts("-1"), 0;
}
printf("%d %d ", a, c);
for (int i = 1; i <= N; i++) {
if (i != a && i != c && i != b && i != d) printf("%d ", i);
}
printf("%d %d\n", d, b);
printf("%d %d ", c, a);
for (int i = 1; i <= N; i++) {
if (i != a && i != c && i != b && i != d) printf("%d ", i);
}
printf("%d %d\n", b, d);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
if (k < n + 1 || n == 4) {
cout << -1 << endl;
return 0;
}
cout << a << " " << c << " ";
for (int x = 1; x <= n; x++) {
if (x != a && x != b && x != c && x != d) {
cout << x << " ";
}
}
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (int x = 1; x <= n; x++) {
if (x != a && x != b && x != c && x != d) {
cout << x << " ";
}
}
cout << b << " " << d;
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, k, a, b, c, d, v[1005], u[1005], cnt;
int main() {
cin >> n >> k;
cin >> a >> b >> c >> d;
v[0] = u[1] = a, v[n - 1] = u[n - 2] = b;
u[0] = v[1] = c, u[n - 1] = v[n - 2] = d;
for (int i = 2; i < n - 2; i++) {
cnt++;
while (cnt == a || cnt == b || cnt == c || cnt == d) cnt++;
v[i] = u[i] = cnt;
}
if (n == 4 || k < n + 1) {
cout << -1;
return 0;
}
for (int i = 0; i < n - 1; i++) cout << v[i] << ' ';
cout << v[n - 1] << endl;
for (int i = 0; i < n - 1; i++) cout << u[i] << ' ';
cout << u[n - 1] << endl;
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int INF = 1000001000;
const int mod = 1000 * 1000 * 1000 + 7;
const int mod9 = 1000 * 1000 * 1000 + 9;
const double PI = 3.1415926535897932;
double sqr(double first) { return first * first; };
long double sqr(long double first) { return first * first; };
long long sqr(long long first) { return first * first; };
long long sqr(int first) { return first * 1LL * first; };
long long gcd(long long a, long long b) {
while (b) a %= b, swap(a, b);
return a;
}
long long bpm(long long a, long long n = -2, long long m = mod) {
n = n >= 0 ? n : m + n;
long long r = 1;
while (n) {
if (n & 1) r = (r * a) % m;
a = (a * a) % m;
n >>= 1;
}
return r;
}
long long dist(long long x1, long long y1, long long x2, long long y2) {
return sqr(x1 - x2) + sqr(y1 - y2);
}
std::ostream& operator<<(std::ostream& os, pair<int, int> p) {
return os << "{" << p.first << " " << p.second << "}";
}
const int N = 5003;
int z[N];
int main() {
int n, k;
scanf("%d %d", &n, &k);
;
int a, b;
scanf("%d %d", &a, &b);
;
int c, d;
scanf("%d %d", &c, &d);
;
set<int> st;
for (int i = 0; i < n; i++) {
st.insert(i + 1);
}
z[0] = a;
z[1] = b;
z[2] = c;
z[3] = d;
st.erase(a);
st.erase(b);
st.erase(c);
st.erase(d);
if (st.size() == 0) {
cout << -1 << endl;
return 0;
}
int e = *st.begin();
st.erase(e);
set<pair<int, int> > rds;
vector<int> r1, r2;
vector<int> in;
while (st.size()) {
in.push_back(*st.begin());
st.erase(st.begin());
}
r1.push_back(a);
for (int first : in) {
r1.push_back(first);
}
r1.push_back(d);
r1.push_back(e);
r1.push_back(c);
r1.push_back(b);
r2.push_back(c);
r2.push_back(b);
r2.push_back(e);
r2.push_back(a);
for (int first : in) {
r2.push_back(first);
}
r2.push_back(d);
for (int i = 1; i < r1.size(); i++) {
pair<int, int> f = {r1[i], r1[i - 1]};
if (f.first > f.second) {
swap(f.first, f.second);
}
rds.insert(f);
}
for (int i = 1; i < r2.size(); i++) {
pair<int, int> f = {r2[i], r2[i - 1]};
if (f.first > f.second) {
swap(f.first, f.second);
}
rds.insert(f);
}
if (rds.size() > k) {
cout << -1 << endl;
return 0;
}
{
for (int i = 0; i < r1.size(); i++)
if (i + 1 == r1.size())
printf("%d\n", r1[i]);
else
printf("%d ", r1[i]);
};
{
for (int i = 0; i < r2.size(); i++)
if (i + 1 == r2.size())
printf("%d\n", r2[i]);
else
printf("%d ", r2[i]);
};
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
cin >> n >> m;
int a, b, c, d;
cin >> a >> b >> c >> d;
if (m - n < 1 || n == 4)
cout << -1;
else {
cout << a << " " << c << " ";
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) continue;
cout << i << " ";
}
cout << d << " " << b;
cout << endl;
cout << c << " " << a << " ";
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) continue;
cout << i << " ";
}
cout << b << " " << d;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, k, a, b, c, d, ic, id;
cin >> n >> k;
cin >> a >> b >> c >> d;
vector<int> ans, ans2;
ans.push_back(a);
if (c != a) {
ans.push_back(c);
}
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) {
continue;
}
ans.push_back(i);
}
if (d != b) {
ans.push_back(d);
}
ans.push_back(b);
for (int i = 0; i < n; i++) {
if (ans[i] == c) {
ic = i;
} else if (ans[i] == d) {
id = i;
}
}
if (id == ic + 1) {
cout << -1;
return 0;
}
if ((a == c && b == d) || (a == d && b == c)) {
} else if (a == c || a == d || b == c || b == d) {
if (k < n) {
cout << -1;
return 0;
}
} else {
if (k < n + 1) {
cout << -1;
return 0;
}
}
int cnt = ic;
int flag = 0;
for (int i = 0; i < n; i++) {
ans2.push_back(ans[cnt]);
if (flag == 0) {
if (cnt == 0) {
cnt = ic + 1;
flag = 1;
} else {
cnt--;
}
} else if (flag == 1) {
cnt++;
if (ans[cnt] == d) {
cnt = n - 1;
flag = 2;
}
} else {
cnt--;
}
}
for (int i = 0; i < n; i++) {
cout << ans[i];
if (i != n) {
cout << " ";
}
}
cout << endl;
for (int i = 0; i < n; i++) {
cout << ans2[i];
if (i != n) {
cout << " ";
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
class C_ {};
template <typename T>
C_& operator<<(C_& __m, const T& __s) {
if (!1) cerr << "\E[91m" << __s << "\E[0m";
return __m;
}
C_ merr;
struct __s {
__s() {
if (1) {
ios_base::Init i;
cin.sync_with_stdio(0);
cin.tie(0);
}
}
~__s() {
merr << "Execution time: " << fixed << setprecision(3)
<< (double)clock() / CLOCKS_PER_SEC << " s.\n";
}
} __S;
int main(void) {
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
a--, b--, c--, d--;
if (n == 4 || k < n + 1) {
cout << "-1" << '\n';
return 0;
}
vector<int> V;
for (int i = 0; i < n; i++) {
if (i == a || i == b || i == c || i == d) continue;
V.push_back(i);
}
cout << a + 1 << " " << c + 1 << " ";
for (int i = 0; i < (int)V.size(); i++) {
cout << V[i] + 1 << " ";
}
cout << d + 1 << " " << b + 1 << '\n';
cout << c + 1 << " " << a + 1 << " ";
for (int i = 0; i < (int)V.size(); i++) {
cout << V[i] + 1 << " ";
}
cout << b + 1 << " " << d + 1 << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long n, k, a, b, c, d;
int main() {
cin >> n >> k >> a >> b >> c >> d;
if (n == 4 || k <= n) {
cout << -1 << endl;
return 0;
}
cout << a << " " << c << " ";
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) cout << i << " ";
}
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) cout << i << " ";
}
cout << b << " " << d << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
int a, b, c, d;
scanf("%d%d", &n, &k);
scanf("%d%d%d%d", &a, &b, &c, &d);
if (n == 4) {
printf("-1");
return 0;
}
if (k < n + 1) {
printf("-1");
return 0;
}
int intermediate = 0;
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) {
intermediate = i;
break;
}
printf("%d ", a);
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d && i != intermediate)
printf("%d ", i);
}
printf("%d %d %d %d\n", c, intermediate, d, b);
printf("%d ", c);
for (int i = n; i >= 1; i--) {
if (i != a && i != b && i != c && i != d && i != intermediate)
printf("%d ", i);
}
printf("%d %d %d %d", a, intermediate, b, d);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class t, class u>
void chmax(t& first, u second) {
if (first < second) first = second;
}
template <class t, class u>
void chmin(t& first, u second) {
if (second < first) first = second;
}
int first, second, c, d;
bool check(int x) { return !(first == x || second == x || c == x || d == x); }
int main() {
int n, m;
scanf("%d", &n);
scanf("%d", &m);
scanf("%d", &first);
scanf("%d", &second);
scanf("%d", &c);
scanf("%d", &d);
if (m < n + 1 || n == 4) return !printf("-1\n");
vector<int> path(n);
assert(n > 4);
path[0] = first;
path[n - 1] = second;
path[1] = c;
path[n - 2] = d;
int pointr = 1;
for (int i = 2; i < n - 2; i++) {
while (!check(pointr)) pointr++;
path[i] = pointr++;
}
for (int i = 0; i < n; i++) printf("%d ", path[i]);
printf("\n");
printf("%d %d ", path[1], path[0]);
for (int i = n - 3; i > 1; i--) printf("%d ", path[i]);
printf("%d %d\n", path[n - 1], path[n - 2]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, k, a, b, c, d;
int main() {
cin >> n >> k >> a >> b >> c >> d;
if (n == 4 || k <= n)
cout << -1;
else {
cout << a << " " << c << " ";
for (int i = 1; i <= n; ++i)
if (i != a && i != b && i != c && i != d) cout << i << " ";
cout << d << " " << b << "\n";
cout << c << " " << a << " ";
for (int i = 1; i <= n; ++i)
if (i != a && i != b && i != c && i != d) cout << i << " ";
cout << b << " " << d;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, k;
int a, b, c, d;
int s[1 << 20];
int viz[1 << 20];
int w;
int main() {
cin >> n >> k;
cin >> a >> b >> c >> d;
if (n == 4 || n + 1 > k) {
cout << -1;
return 0;
}
s[1] = a;
s[n] = b;
s[2] = c;
s[4] = d;
viz[a] = viz[b] = viz[c] = viz[d] = 1;
int q = 1;
for (int i = 1; i <= n; i++)
if (s[i] == 0) {
while (viz[q]) q++;
s[i] = q;
viz[q] = 1;
}
for (int i = 1; i <= n; i++) cout << s[i] << ' ';
cout << '\n';
cout << s[2] << ' ' << s[1] << ' ' << s[3] << ' ';
for (int i = n; i >= 4; i--) cout << s[i] << ' ';
}
|
#include <bits/stdc++.h>
using namespace std;
bool isprime(long long n) {
long long i;
if (n == 2 || n == 3) return 1;
long long flag = 0;
for (i = 2; i <= sqrt(n) + 1; i++) {
if (n % i == 0) {
flag = 1;
break;
}
}
if (flag)
return 0;
else
return 1;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t;
t = 1;
while (t--) {
long long n, m;
cin >> n >> m;
long long a, b, c, d;
cin >> a >> b >> c >> d;
long long arr[n];
if (m < n + 1 || n == 4) {
cout << -1;
continue;
}
arr[0] = a;
arr[n - 1] = b;
arr[1] = c;
arr[n - 2] = d;
long long idx = 2;
for (long long i = 1; i < n + 1; i++) {
if (i != a && i != b && i != c && i != d) {
arr[idx] = i;
idx++;
}
}
for (long long i = 0; i < n; i++) cout << arr[i] << " ";
cout << "\n";
cout << c << " " << a << " ";
for (long long i = 2; i < n - 2; i++) {
cout << arr[i] << " ";
}
cout << arr[n - 1] << " " << arr[n - 2];
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
if (n >= k || n == 4) {
cout << "-1" << '\n';
return 0;
}
cout << a << ' ' << c << ' ';
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) continue;
cout << i << ' ';
}
cout << d << ' ' << b << '\n';
cout << c << ' ' << a << ' ';
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) continue;
cout << i << ' ';
}
cout << b << ' ' << d << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1050;
int x[maxn];
int vis[maxn];
int main() {
int n, m, a, b, c, d;
scanf("%d %d", &n, &m);
scanf("%d %d %d %d", &a, &b, &c, &d);
if (m < n + 1 || n == 4)
printf("-1\n");
else {
memset(vis, 0, sizeof(vis));
vis[a] = vis[b] = vis[c] = vis[d] = 1;
int cnt = 1;
for (int i = 1; i <= n - 4; i++) {
while (vis[cnt] == 1) {
cnt++;
if (cnt > n) cnt = 1;
}
x[i] = cnt;
vis[cnt] = 1;
}
printf("%d %d ", a, c);
for (int i = 1; i < n - 4; i++) printf("%d ", x[i]);
printf("%d", x[n - 4]);
printf(" %d %d\n", d, b);
printf("%d %d ", c, a);
for (int i = 1; i < n - 4; i++) printf("%d ", x[i]);
printf("%d", x[n - 4]);
printf(" %d %d\n", b, d);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n = 0;
cin >> n;
int m = 0;
cin >> m;
if (n == 4) {
cout << -1;
return 0;
}
if (m < n + 1) {
cout << -1;
return 0;
}
map<int, int> mapping;
vector<int> used(n + 1, 0);
set<int> unused;
for (int j = 0; j < n; j++) unused.insert(j);
for (int j = 0; j < 4; j++) {
int x = 0;
cin >> x;
used[x] = 1;
mapping[*(unused.begin())] = x;
unused.erase(unused.begin());
}
for (int j = 1; j <= n; ++j) {
if (used[j] == 0) {
mapping[*(unused.begin())] = j;
unused.erase(unused.begin());
}
}
cout << mapping[0] << " " << mapping[2] << " " << mapping[4] << " ";
for (int j = 5; j < n; j++) cout << mapping[j] << " ";
cout << mapping[3] << " " << mapping[1] << endl;
cout << mapping[2] << " " << mapping[0] << " " << mapping[4] << " ";
for (int j = 5; j < n; j++) cout << mapping[j] << " ";
cout << mapping[1] << " " << mapping[3] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n, k;
cin >> n >> k;
long long a, b, c, d;
cin >> a >> b >> c >> d;
if (k <= n or n <= 4) {
cout << -1;
return 0;
}
for (long long i = 1; i <= 2; i++) {
cout << a << ' ' << c << ' ';
for (long long i = 1; i <= n; i++) {
if (i == a or i == b or i == c or i == d) continue;
cout << i << ' ';
}
cout << d << ' ' << b << endl;
swap(b, d);
swap(a, c);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
if (k < (n + 1) or n == 4)
cout << -1 << endl;
else {
vector<int> v;
for (int i = 1; i <= n; i++)
if (i != a and i != b and i != c and i != d) v.push_back(i);
cout << a << ' ' << c << ' ';
for (int i : v) cout << i << ' ';
cout << d << ' ' << b << endl;
cout << c << ' ' << a << ' ';
for (int i : v) cout << i << ' ';
cout << b << ' ' << d << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
vector<int> vi;
const int mod = int(1e9) + 7, INF = 0x3fffffff;
const int maxn = 1e5 + 13;
int main(void) {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
bool ok = false;
if (n == 4) {
cout << -1 << endl;
} else {
if (k >= n + 1)
ok = true;
else
cout << -1 << endl;
}
if (ok) {
cout << a << " " << c << " ";
for (int i = 1; i <= n; i++) {
if (i != a && i != c && i != d && i != b) cout << i << " ";
}
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (int i = 1; i <= n; i++) {
if (i != a && i != c && i != d && i != b) cout << i << " ";
}
cout << b << " " << d << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
long long powmod(long long a, long long b) {
long long res = 1;
if (a >= mod) a %= mod;
for (; b; b >>= 1) {
if (b & 1) res = res * a;
if (res >= mod) res %= mod;
a = a * a;
if (a >= mod) a %= mod;
}
return res;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long n, k, i, j;
long long mark[100010];
long long a, b, c, d;
vector<long long> vec;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
cin >> a >> b >> c >> d;
if (k < n + 1 || n < 5) {
cout << "-1";
return 0;
} else {
vec.push_back(a);
vec.push_back(c);
for (i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d)
continue;
else {
vec.push_back(i);
}
}
vec.push_back(d);
vec.push_back(b);
for (i = 0; i < n; i++) cout << vec[i] << " ";
cout << "\n";
vec.clear();
vec.push_back(c);
vec.push_back(a);
for (i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d)
continue;
else {
vec.push_back(i);
}
}
vec.push_back(b);
vec.push_back(d);
for (i = 0; i < n; i++) cout << vec[i] << " ";
vec.clear();
}
}
|
#include <bits/stdc++.h>
using namespace std;
int n, k, a, b, c, d, i, j;
void print() {
printf("%d %d", a, c);
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) continue;
printf(" %d", i);
}
printf(" %d %d\n", d, b);
swap(a, c);
swap(b, d);
printf("%d %d", a, c);
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) continue;
printf(" %d", i);
}
printf(" %d %d\n", d, b);
}
int main() {
scanf("%d%d", &n, &k);
scanf("%d%d%d%d", &a, &b, &c, &d);
if (n == 4)
printf("-1\n");
else if (k < n - 1)
printf("-1\n");
else if (k == n - 1) {
if (a == c && b == d)
print();
else
printf("-1\n");
} else if (k == n) {
if (a == c || b == d)
print();
else
printf("-1\n");
} else
print();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, k, a, b, c, d;
int main() {
scanf("%d%d", &n, &k);
scanf("%d%d%d%d", &a, &b, &c, &d);
if (a == c && b == d || a == d && b == c) {
if (n - 1 > k) {
puts("-1");
return 0;
}
printf("%d ", a);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d ", b);
puts("");
if (a == c)
printf("%d ", c);
else
printf("%d ", d);
if (a == c) {
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
} else {
for (int i = n; i >= 1; i--)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
}
if (a == c)
printf("%d ", d);
else
printf("%d ", c);
return 0;
}
if (a == c || a == d || b == c || b == d) {
if (n > k) {
puts("-1");
return 0;
}
if (a == c) {
printf("%d ", a);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d %d\n", d, b);
printf("%d ", a);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d %d\n", b, d);
} else if (a == d) {
printf("%d %d", a);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d %d\n", c, b);
printf("%d %d", c, b);
for (int i = n; i >= 1; i--)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d\n", d);
} else if (b == c) {
printf("%d %d", a, d);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d\n", b);
printf("%d ", c);
for (int i = n; i >= 1; i--)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d\n", a, d);
} else {
printf("%d %d", a, c);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d\n", b);
printf("%d %d", c, a);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d\n", b);
}
} else {
if (n + 1 > k || n <= 4) {
puts("-1");
return 0;
}
printf("%d %d ", a, c);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d %d\n", d, b);
printf("%d %d ", c, a);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d %d\n", b, d);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, a, b, c, d;
scanf("%d%d%d%d%d%d", &n, &k, &a, &b, &c, &d);
if (n == 4 || k <= n) return printf("-1"), 0;
printf("%d %d ", a, c);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d %d\n%d %d ", d, b, c, a);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d %d\n", b, d);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1100;
int n, k, a, b, c, d, id[N], tr[N];
inline int read() {
int f = 1, x = 0;
char s = getchar();
while (s < '0' || s > '9') {
if (s == '-') f = -1;
s = getchar();
}
while (s >= '0' && s <= '9') {
x = x * 10 + s - '0';
s = getchar();
}
return x * f;
}
signed main() {
n = read();
k = read();
a = read();
b = read();
c = read();
d = read();
if (k <= n || n == 4) {
printf("-1\n");
return 0;
}
id[a] = 1, id[b] = n;
id[c] = 2, id[d] = n - 1;
int cnt = 2;
for (int i = 1; i <= n; i++) {
if (id[i]) continue;
id[i] = ++cnt;
}
for (int i = 1; i <= n; i++) tr[id[i]] = i;
for (int i = 1; i <= n; i++) printf("%d ", tr[i]);
printf("\n");
printf("%d %d ", c, a);
for (int i = 3; i <= n - 2; i++) printf("%d ", tr[i]);
printf("%d %d\n", b, d);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, a, b, c, d;
cin >> N >> M >> a >> b >> c >> d;
if (N > 4) {
M -= 6;
if (M < N - 5)
cout << "-1\n";
else {
cout << a << " " << c;
for (int i = 1; i <= N; i++) {
if (i == a || i == b || i == c || i == d) continue;
cout << " " << i;
}
cout << " " << d << " " << b << "\n";
cout << c << " " << a;
for (int i = 1; i <= N; i++) {
if (i == a || i == b || i == c || i == d) continue;
cout << " " << i;
}
cout << " " << b << " " << d << "\n";
}
} else
cout << "-1\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if (k - n < 1 || n == 4) {
cout << -1;
return 0;
}
int a, b, c, d;
cin >> a >> b >> c >> d;
cout << a << " " << c << " ";
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) cout << i << " ";
}
cout << d << " " << b << '\n';
cout << c << " " << a << " ";
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << " ";
cout << b << " " << d;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, a, b, c, d, i;
scanf("%d%d%d%d%d%d", &n, &k, &a, &b, &c, &d);
int arr[n + 2];
for (i = 1; i <= n; i++) arr[i] = 0;
arr[a] = 1;
arr[c] = 1;
vector<int> v;
v.push_back(a);
v.push_back(c);
if (n == 4 || k < n + 1)
cout << -1;
else {
for (i = 1; i <= n; i++) {
if (i != a && i != c && i != b && i != d) break;
}
v.push_back(i);
v.push_back(d);
arr[i] = 1;
arr[d] = 1;
for (i = 1; i <= n; i++) {
if (arr[i] == 0 && i != b) v.push_back(i);
}
v.push_back(b);
for (i = 0; i < n; i++) cout << v[i] << " ";
cout << endl;
cout << v[1] << " " << v[0] << " " << v[2] << " ";
for (i = n - 1; i >= 3; i--) cout << v[i] << " ";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
ifstream in("in.txt");
ofstream out("ubuntzei.out");
bool first[1001];
int main() {
int n, k, a, b, c, d, i;
cin >> n >> k >> a >> b >> c >> d;
first[a] = first[b] = first[c] = first[d] = 1;
if (n + 1 > k || n == 4) {
cout << -1;
return 0;
}
cout << a << " " << c << " ";
for (i = 1; i <= n; ++i)
if (!first[i]) cout << i << " ";
cout << d << " " << b << "\n";
cout << c << " " << a << " ";
for (i = 1; i <= n; ++i)
if (!first[i]) cout << i << " ";
cout << b << " " << d << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 100;
const long double eps = 1e-11;
const long double pi = acos(-1.0L);
int myrand() { return rand(); }
unsigned rdtsc() {
unsigned ans;
asm("rdtsc" : "=a"(ans));
return ans;
}
int rnd(int x) { return myrand() % x; }
void precalc() {}
int n, k;
int a, b, c, d;
bool read() {
if (scanf("%d%d", &n, &k) < 2) {
return false;
}
scanf("%d%d%d%d", &a, &b, &c, &d);
return true;
}
void solve() {
if (n <= 4 || k < n + 1) {
printf("-1\n");
return;
}
vector<int> path;
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) {
path.push_back(i);
}
}
printf("%d %d ", a, c);
for (int i = 0; i < ((int)((path).size())); i++) {
printf("%d ", path[i]);
}
printf("%d %d\n", d, b);
printf("%d %d ", c, a);
for (int i = 0; i < ((int)((path).size())); i++) {
printf("%d ", path[i]);
}
printf("%d %d\n", b, d);
}
int main() {
srand(rdtsc());
precalc();
while (true) {
if (!read()) {
break;
}
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int n, k;
int a, b, c, d;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
cin >> a >> b >> c >> d;
if (n == 4 || k <= n) return 0 * puts("-1");
cout << a << ' ' << c << ' ';
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) cout << i << ' ';
}
cout << d << ' ' << b << '\n';
cout << c << ' ' << a << ' ';
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) cout << i << ' ';
}
cout << b << ' ' << d << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, k, a, b, c, d;
int main() {
ios_base::sync_with_stdio(false);
cin >> n >> k >> a >> b >> c >> d;
if (n == 4 or k < n + 1)
cout << "-1\n";
else {
cout << a << " " << c << " ";
for (int i = 1; i <= n; i++) {
if (i == a or i == b or i == c or i == d) continue;
cout << i << " ";
}
cout << d << " " << b << "\n";
cout << c << " " << a << " ";
for (int i = 1; i <= n; i++) {
if (i == a or i == b or i == c or i == d) continue;
cout << i << " ";
}
cout << b << " " << d << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline void writeln2() { cout << "\n"; }
inline void writeln() { cout << "\n"; }
inline void readln() {}
template <typename T>
inline void read(T&);
template <typename T>
inline void priws(T);
template <typename T>
inline void print(T);
void err(vector<string>::iterator it) { ++it; }
template <typename Head, typename... Tail>
inline void readln(Head& head, Tail&... tail) {
read(head);
readln(tail...);
}
template <typename Head, typename... Tail>
inline void writeln2(Head head, Tail... tail) {
print(head);
writeln2(tail...);
}
template <typename Head, typename... Tail>
inline void writeln(Head head, Tail... tail) {
priws(head);
writeln2(tail...);
}
template <typename T>
inline void writeln_range(T f, T s) {
if (f != s)
for (auto i = f; i != s; ++i) writeln(*i);
}
template <typename Head, typename... Tail>
inline void err(vector<string>::iterator it, Head head, Tail... tail) {
writeln((*it).substr((*it)[0] == ' '), "=", head);
err(++it, tail...);
}
vector<string> split(const string& s, char c) {
vector<string> v;
stringstream ss(s);
string x;
while (getline(ss, x, c)) v.push_back(x);
return move(v);
}
void fail() {
writeln(-1);
exit(0);
}
void run() {
int n, k, a, b, c, d;
readln(n, k, a, b, c, d);
if (n == 4 || k <= n) fail();
vector<int> x(n), y(n), z(n);
set<int> indices;
for (int i = 1; i < (int)(n + 1); ++i) indices.insert(i);
indices.erase(a);
indices.erase(b);
indices.erase(c);
indices.erase(d);
x[0] = a;
x[1] = b;
x[2] = c;
x[3] = d;
auto it = indices.begin();
for (int i = 4; i < n; ++i, it++) x[i] = *it;
y[0] = x[0];
y[1] = x[2];
y[2] = x[4];
y[3] = x[3];
for (int i = 4; i < (int)(n - 1); ++i) y[i] = x[i + 1];
y[n - 1] = x[1];
z[0] = x[2];
z[1] = x[0];
z[2] = x[4];
z[3] = x[1];
for (int i = 4; i < (int)(n - 1); ++i) z[i] = x[n - i + 3];
z[n - 1] = x[3];
writeln(y);
writeln(z);
}
int main() {
ios_base::sync_with_stdio(false);
run();
return 0;
}
template <typename T>
inline ostream& operator<<(ostream& os, vector<T>& _a);
template <typename T1, typename T2>
inline istream& operator>>(istream& is, pair<T1, T2>& _a) {
return is >> _a.first >> _a.second;
}
template <typename T1, typename T2>
inline ostream& operator<<(ostream& os, pair<T1, T2>& _a) {
return os << _a.first << " " << _a.second;
}
template <typename T>
inline ostream& operator<<(ostream& os, vector<T>& _a) {
if (_a.size())
os << _a[0];
else
os << "\n";
for (int i = 1; i < _a.size(); ++i)
os << "\n "[is_fundamental<T>::value] << _a[i];
return os;
}
template <typename T>
inline istream& operator>>(istream& is, vector<T>& _a) {
if (_a.size() == 0) {
int _n;
is >> _n;
_a.resize(_n);
}
for (int i = 0; i < _a.size(); ++i) is >> _a[i];
return is;
}
template <typename T>
inline void print(T _a) {
cout << " " << _a;
}
template <typename T>
inline void priws(T _a) {
cout << _a;
}
template <typename T>
inline void read(T& _a) {
cin >> _a;
}
|
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-5;
const int oo = 0x3f3f3f3f;
template <class T>
inline void checkmin(T &a, T b) {
if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
return x * x;
}
template <class T>
inline T lowbit(T n) {
return (n ^ (n - 1)) & n;
}
template <class T>
inline int countbit(T n) {
return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
template <class T>
inline T gcd(T a, T b) {
T c;
while (a != 0) {
c = a;
a = b % a;
b = c;
}
return b;
}
template <class T>
inline T mabs(T a) {
if (a < 0)
return -a;
else
return a;
}
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<string> VS;
#pragma comment(linker, "/STACK:36777216")
int TEST_TO;
int TEST_FROM;
inline int solve(int testnum) {
int n, k, a, b, c, d;
scanf("%d%d%d%d%d%d", &n, &k, &a, &b, &c, &d);
if (n == 4 || k <= n) {
printf("-1\n");
return 0;
}
printf("%d %d ", a, c);
for (int i = (1); i < int(n + 1); i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d %d\n", d, b);
printf("%d %d ", c, a);
for (int i = (1); i < int(n + 1); i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d %d\n", b, d);
return 0;
}
int main(int argc, char *argv[]) {
ios::sync_with_stdio(false);
int t = 1;
if (argc > 1) t = atoi(argv[1]);
TEST_FROM = 1;
TEST_TO = t;
for (int _t = (1); _t < int(t + 1); _t++) {
int ret = solve(_t);
if (ret == -1) break;
}
return 0;
}
|
#include <bits/stdc++.h>
long long p = 1000000007;
using namespace std;
long long sq(long long i) { return i * i; }
long long fact(long n) {
long ans = 1;
for (long i = 1; i <= n; i++) ans = (ans * i) % p;
return ans;
}
void dfs(vector<long> v[], vector<long> &df, long cov[], long i) {
df.push_back(i);
for (long j = 0; j < v[i].size(); j++) {
if (cov[v[i][j]] == 0) {
cov[v[i][j]] = cov[i];
dfs(v, df, cov, v[i][j]);
}
}
}
void djikstra(vector<pair<long, long>> v[], long d[], long par[], long s,
long n) {
for (long i = 0; i < n; i++) {
d[i] = 1000000001;
par[i] = -1;
}
par[s] = s;
d[s] = 0;
bool cov[n];
for (long i = 0; i < n; i++) cov[i] = 0;
long u = -1;
for (int j = 0; j < n; j++) {
u = -1;
for (long i = 0; i < n; i++) {
if (!cov[i] && (d[i] < d[u] || u == -1)) u = i;
}
cov[u] = 1;
for (long i = 0; i < v[u].size(); i++) {
if (d[v[u][i].first] > d[u] + v[u][i].second) {
d[v[u][i].first] = d[u] + v[u][i].second;
par[v[u][i].first] = u;
}
}
}
}
long findConnComp(vector<long> v[], long cov[], long n) {
long j = 0;
vector<long> df;
for (long i = 0; i < n; i++) cov[i] = 0;
for (long i = 0; i < n; i++) {
if (!cov[i]) {
cov[i] = ++j;
dfs(v, df, cov, i);
}
}
return j;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long n, k;
cin >> n >> k;
if (k < n + 1 || n == 4)
cout << -1;
else {
long a, b, c, d;
cin >> a >> b >> c >> d;
long x[n];
for (long i = 0; i < n; i++) x[i] = 1;
long j = 1;
x[0] = a;
x[1] = c;
x[n - 2] = d;
x[n - 1] = b;
for (long i = 2; i < n - 2; i++) {
while (1) {
if (j != a && j != b && j != c && j != d)
break;
else
j++;
}
x[i] = j++;
}
for (long i = 0; i < n; i++) cout << x[i] << " ";
cout << "\n";
cout << x[1] << " " << x[0] << " ";
for (long i = 2; i < n - 2; i++) cout << x[i] << " ";
cout << x[n - 1] << " " << x[n - 2];
}
}
|
#include <bits/stdc++.h>
using namespace std;
int n, k, a, b, c, d, e;
int main() {
scanf("%d%d%d%d%d%d", &n, &k, &a, &b, &c, &d);
if (n >= k || n == 4) {
printf("-1\n");
return 0;
}
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) e = i, i = n + 1;
printf("%d ", a);
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d && i != e) printf("%d ", i);
printf("%d %d %d %d\n", c, e, d, b);
printf("%d ", c);
for (int i = n; i; i--)
if (i != a && i != b && i != c && i != d && i != e) printf("%d ", i);
printf("%d %d %d %d\n", a, e, b, d);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int a, b, c, d;
cin >> a >> b >> c >> d;
if (m <= n || n == 4) {
cout << -1 << endl;
return 0;
} else {
vector<int> ans(n);
ans[0] = a;
ans[1] = c;
ans[3] = d;
int id = 2;
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) {
ans[id] = i;
id++;
if (id == 3) id++;
}
ans[n - 1] = b;
for (int i = 0; i < n; i++) cout << ans[i] << " ";
cout << endl;
int len = 0;
cout << ans[1] << " " << ans[0] << " " << ans[2] << " " << ans[n - 1]
<< " ";
for (int i = n - 2; i >= 3; i--) cout << ans[i] << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> v;
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
v.push_back(a);
v.push_back(c);
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) v.push_back(i);
}
v.push_back(d);
v.push_back(b);
if (k >= n + 1 && n > 4) {
for (int i = 0; i < n; i++) {
cout << v[i] << " ";
}
cout << "\n";
swap(v[0], v[1]);
swap(v[n - 1], v[n - 2]);
for (int i = 0; i < n; i++) {
cout << v[i] << " ";
}
} else {
cout << -1 << "\n";
}
}
|
#include <bits/stdc++.h>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, k, a, b, c, d;
std::cin >> n >> k >> a >> b >> c >> d;
--a;
--b;
--c;
--d;
if (n == 4) {
std::cout << -1 << std::endl;
return 0;
}
if (k <= n) {
std::cout << -1 << std::endl;
return 0;
}
std::vector<int> free;
for (int i = 0; i < n; ++i) {
if (i == a || i == b | i == c || i == d) {
continue;
}
free.push_back(i);
}
std::cout << a + 1 << " " << c + 1 << " ";
for (int i = 0; i < free.size(); ++i) {
std::cout << free[i] + 1 << " ";
}
std::cout << d + 1 << " " << b + 1 << std::endl;
std::cout << c + 1 << " " << a + 1 << " ";
for (int i = 0; i < free.size(); ++i) {
std::cout << free[i] + 1 << " ";
}
std::cout << b + 1 << " " << d + 1 << std::endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, K;
cin >> n >> K;
int a, b, c, d;
cin >> a >> b >> c >> d;
if (n == 4 || K <= n) {
puts("-1");
return 0;
}
vector<int> v;
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) continue;
v.push_back(i);
}
cout << a << ' ' << c;
for (int i : v) cout << ' ' << i;
cout << ' ' << d << ' ' << b << endl;
cout << c << ' ' << a;
for (int i : v) cout << ' ' << i;
cout << ' ' << b << ' ' << d << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
bool comp(int x, int y) { return x > y; }
int main() {
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
vector<int> ans;
for (int i = 0; i < n; i++)
if (i + 1 != a && i + 1 != b && i + 1 != c && i + 1 != d)
ans.push_back(i + 1);
if (n <= 4 || k <= n)
cout << -1 << endl;
else {
cout << a << " " << c << " ";
int len = ans.size();
for (int i = 0; i < len; i++) cout << ans[i] << " ";
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (int i = 0; i < len; i++) cout << ans[i] << " ";
cout << b << " " << d << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, k;
int main() {
scanf("%d%d", &n, &k);
if (n <= 4 || k < n + 1) {
puts("-1");
return 0;
}
int a, b, c, d;
scanf("%d%d%d%d", &a, &b, &c, &d);
printf("%d %d", a, c);
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) printf(" %d", i);
}
printf(" %d %d\n", d, b);
printf("%d %d", c, a);
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) printf(" %d", i);
}
printf(" %d %d\n", b, d);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, a, b, c, d;
cin >> n >> k >> a >> b >> c >> d;
if (n == 4 || k < n + 1)
cout << "-1\n";
else {
cout << a << ' ' << c << ' ';
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << d << ' ' << b << '\n';
cout << c << ' ' << a << ' ';
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << b << ' ' << d << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
inline int cmp(double x, double y = 0, double tol = 1e-10) {
return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
int main() {
int n, k;
scanf("%d %d", &n, &k);
if (n == 4 || k <= n) {
printf("-1\n");
return 0;
}
int a, b, c, d;
scanf("%d %d %d %d", &a, &b, &c, &d);
vector<int> vet;
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) vet.push_back(i);
printf("%d %d ", a, c);
for (auto v : vet) printf("%d ", v);
printf("%d %d\n", d, b);
printf("%d %d ", c, a);
for (auto v : vet) printf("%d ", v);
printf("%d %d\n", b, d);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
if (a == b or c == d) {
cout << -1 << '\n';
return 0;
}
if (a == c and b == d) {
cout << a << ' ';
for (int i = 1; i <= n; ++i) {
if (i != a and i != b) cout << i << ' ';
}
cout << b << '\n';
cout << c << ' ';
for (int i = 1; i <= n; ++i) {
if (i != a and i != b) cout << i << ' ';
}
cout << d << '\n';
} else if (a == d and c == b) {
cout << a << ' ';
for (int i = 1; i <= n; ++i) {
if (i != a and i != b) cout << i << ' ';
}
cout << b << '\n';
cout << c << ' ';
for (int i = n; i > 0; --i) {
if (i != a and i != b) cout << i << ' ';
}
cout << d << '\n';
} else if (a == c) {
if (k >= n) {
cout << a << ' ';
for (int i = 1; i <= n; ++i) {
if (i != a and i != b and i != c and i != d) cout << i << ' ';
}
cout << d << ' ';
cout << b << '\n';
cout << a << ' ';
for (int i = 1; i <= n; ++i) {
if (i != a and i != b and i != c and i != d) cout << i << ' ';
}
cout << b << ' ';
cout << d << '\n';
} else
cout << "-1\n";
} else if (a == d) {
if (k >= n) {
cout << a << ' ';
for (int i = 1; i <= n; ++i) {
if (i != a and i != b and i != c and i != d) cout << i << ' ';
}
cout << c << ' ';
cout << b << '\n';
cout << c << ' ';
cout << b << ' ';
for (int i = n; i > 0; --i) {
if (i != a and i != b and i != c and i != d) cout << i << ' ';
}
cout << d << '\n';
} else
cout << "-1\n";
} else if (b == d) {
if (k >= n) {
cout << a << ' ';
cout << c << ' ';
for (int i = 1; i <= n; ++i) {
if (i != a and i != b and i != c and i != d) cout << i << ' ';
}
cout << b << '\n';
cout << c << ' ';
cout << a << ' ';
for (int i = 1; i <= n; ++i) {
if (i != a and i != b and i != c and i != d) cout << i << ' ';
}
cout << d << '\n';
} else
cout << "-1\n";
} else if (b == c) {
if (k >= n) {
cout << a << ' ';
cout << d << ' ';
for (int i = 1; i <= n; ++i) {
if (i != a and i != b and i != c and i != d) cout << i << ' ';
}
cout << b << '\n';
cout << c << ' ';
for (int i = n; i > 0; --i) {
if (i != a and i != b and i != c and i != d) cout << i << ' ';
}
cout << a << ' ';
cout << d << '\n';
} else
cout << "-1\n";
} else if (k > n and n != 4) {
cout << a << ' ';
cout << c << ' ';
for (int i = 1; i <= n; ++i) {
if (i != a and i != b and i != c and i != d) cout << i << ' ';
}
cout << d << ' ';
cout << b << '\n';
cout << c << ' ';
cout << a << ' ';
for (int i = 1; i <= n; ++i) {
if (i != a and i != b and i != c and i != d) cout << i << ' ';
}
cout << b << ' ';
cout << d << '\n';
} else
cout << "-1\n";
}
|
#include <bits/stdc++.h>
using namespace std;
int n, k, a, b, c, d;
set<int> s;
int main() {
scanf("%d%d", &n, &k);
scanf("%d%d%d%d", &a, &b, &c, &d);
if (k <= n || n == 4)
printf("-1\n");
else {
for (int i = 1; i <= n; i++) s.insert(i);
s.erase(a);
s.erase(b);
s.erase(c);
s.erase(d);
printf("%d %d ", a, c);
for (set<int>::iterator it = s.begin(); it != s.end(); it++)
printf("%d ", *it);
printf("%d %d\n", d, b);
printf("%d %d ", c, a);
for (set<int>::iterator it = s.begin(); it != s.end(); it++)
printf("%d ", *it);
printf("%d %d\n", b, d);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long int n, k;
cin >> n >> k;
long long int a, b, c, d;
cin >> a >> b >> c >> d;
if (n == 4 || k < n + 1) {
cout << -1 << "\n";
return 0;
}
long long int i;
deque<long long int> q, q2;
for (i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) {
continue;
}
q.push_back(i);
}
q.push_front(c);
q.push_front(a);
q.push_back(d);
q.push_back(b);
for (auto i : q) cout << i << " ";
cout << "\n";
long long int x = q.front();
q.pop_front();
q2.push_back(x);
q2.push_front(q.front());
q.pop_front();
q2.push_back(q.front());
q.pop_front();
while (true) {
x = q.front();
q.pop_front();
if (x == d) {
q.push_front(x);
break;
}
q2.push_back(x);
}
while (true) {
x = q.back();
q.pop_back();
q2.push_back(x);
if (x == d) break;
}
for (auto i : q2) cout << i << " ";
cout << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, a, b, c, d;
scanf("%d %d %d %d %d %d", &n, &k, &a, &b, &c, &d);
if (k < n + 1 || n == 4) {
printf("-1\n");
return 0;
}
bool marc[1010] = {};
vector<int> resp;
resp.reserve(n);
resp.push_back(a);
resp.push_back(c);
marc[a] = marc[c] = marc[b] = marc[d] = true;
for (int i = 1; i <= n; i++)
if (!marc[i]) resp.push_back(i);
resp.push_back(d), resp.push_back(b);
for (int i = 0; i < n; i++) printf("%d ", resp[i]);
printf("\n");
swap(resp[0], resp[1]);
swap(resp[n - 2], resp[n - 1]);
for (int i = 0; i < n; i++) printf("%d ", resp[i]);
printf("\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, k, a, b, c, d;
int main() {
ios_base::sync_with_stdio(false);
cin >> n >> k;
cin >> a >> b >> c >> d;
if (n <= 4) {
cout << -1;
return 0;
}
if (k < n + 1) {
cout << -1;
return 0;
}
cout << a << " " << c << " ";
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) continue;
cout << i << " ";
}
cout << d << " " << b << "\n";
cout << c << " " << a << " ";
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) continue;
cout << i << " ";
}
cout << b << " " << d << "\n";
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3 + 7;
int n, k, a, b, c, d;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k >> a >> b >> c >> d;
if (n == 4 || k < (n + 1)) {
cout << -1 << "\n";
return 0;
}
vector<int> r1, r2;
r1.push_back(a);
r1.push_back(c);
for (int i = 1; i <= n; ++i) {
if (i != a && i != b && i != c && i != d) {
r1.push_back(i);
}
}
r1.push_back(d);
r1.push_back(b);
r2.push_back(c);
r2.push_back(a);
for (int i = 2; i < n - 2; ++i) {
r2.push_back(r1[i]);
}
r2.push_back(b);
r2.push_back(d);
for (int i = 0; i < n; ++i) {
cout << r1[i] << " ";
}
cout << "\n";
for (int i = 0; i < n; ++i) {
cout << r2[i] << " ";
}
cout << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector<int> val(4);
for (int i = 0; i < 4; i++) cin >> val[i];
if (n < 5 || k < n + 1) {
cout << "-1\n";
return;
}
vector<int> city(n, 0);
int mid = n / 2;
city[mid] = val[2], city[mid + 1] = val[3];
city[0] = val[0], city[n - 1] = val[1];
set<int> s;
for (int i = 1; i <= n; i++) s.insert(i);
for (auto i : val) s.erase(i);
for (int i = 0; i < n; i++)
if (city[i] == 0) city[i] = (*s.begin()), s.erase(s.begin());
cout << city[0] << " ";
for (int i = mid; i > 0; i--) cout << city[i] << " ";
for (int i = mid + 1; i < n; i++) cout << city[i] << " ";
cout << endl;
cout << city[mid] << " ";
for (int i = 0; i < mid; i++) cout << city[i] << " ";
for (int i = n - 1; i >= mid + 1; i--) cout << city[i] << " ";
cout << endl;
}
int main() {
ios_base ::sync_with_stdio(false);
cin.tie(NULL);
int t;
t = 1;
while (t--) solve();
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if (n <= 4 || k <= n) {
cout << -1 << endl;
return 0;
}
int a, b, c, d;
cin >> a >> b >> c >> d;
cout << a << " " << c;
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) {
cout << " " << i;
}
}
cout << " " << d << " " << b;
cout << endl;
cout << c << " " << a;
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) {
cout << " " << i;
}
}
cout << " " << b << " " << d;
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, arr[n], i, j, a, b, c, d;
cin >> n >> k >> a >> b >> c >> d;
if (n <= 4 || k <= n)
cout << -1 << endl;
else {
cout << a << " " << c << " ";
for (i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << " ";
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << " ";
cout << b << " " << d << endl;
}
}
|
#include <bits/stdc++.h>
int main() {
int n, k, a, b, c, d;
scanf("%d%d%d%d%d%d", &n, &k, &a, &b, &c, &d);
if (k <= n || n <= 4) {
puts("-1");
return 0;
}
printf("%d %d ", a, c);
for (int p = 1; p <= n; p++) {
if (p != a && p != b && p != c && p != d) {
printf("%d ", p);
}
}
printf("%d %d\n", d, b);
printf("%d %d ", c, a);
for (int p = 1; p <= n; p++) {
if (p != a && p != b && p != c && p != d) {
printf("%d ", p);
}
}
printf("%d %d\n", b, d);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int arr[5002][5002];
int main() {
long long int n, k, a, b, c, d, i;
cin >> n >> k;
cin >> a >> b >> c >> d;
if (n == 4 || k < n + 1)
cout << "-1" << endl;
else {
cout << a << " " << c << " ";
for (i = 0; i < n; i++) {
if (i + 1 == a || i + 1 == b || i + 1 == c || i + 1 == d) continue;
cout << i + 1 << " ";
}
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (i = 0; i < n; i++) {
if (i + 1 == a || i + 1 == b || i + 1 == c || i + 1 == d) continue;
cout << i + 1 << " ";
}
cout << b << " " << d << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
scanf("%d %d", &n, &k);
int a, b, c, d;
scanf("%d %d", &a, &b);
scanf("%d %d", &c, &d);
if (n == 4 || k < n + 1) {
printf("%d", -1);
} else {
printf("%d ", a);
printf("%d ", c);
for (int i = 1; i < n + 1; i++) {
if (i != a && i != b && i != c && i != d) {
printf("%d ", i);
}
}
printf("%d ", d);
printf("%d\n", b);
printf("%d ", c);
printf("%d ", a);
for (int i = 1; i < n + 1; i++) {
if (i != a && i != b && i != c && i != d) {
printf("%d ", i);
}
}
printf("%d ", b);
printf("%d", d);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double PI = 3.14159265358979323846;
int rx[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int ry[8] = {0, -1, 1, 0, -1, 1, 1, -1};
int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n, k, a, b, c, d, h;
bool u[1111];
int main() {
ios_base::sync_with_stdio(0);
cin >> n >> k >> a >> b >> c >> d;
if (k <= n || n == 4)
cout << -1;
else {
u[a] = 1, u[b] = 1, u[c] = 1, u[d] = 1;
for (int i = 1; i <= n; i++) {
if (!u[i]) {
h = i;
u[i] = 1;
break;
}
}
cout << a << " " << c << " " << h << " " << d << " ";
for (int i = 1; i <= n; i++) {
if (!u[i]) cout << i << " ";
}
cout << b << endl;
cout << c << " " << a << " " << h << " " << b << " ";
for (int i = n; i >= 1; i--) {
if (!u[i]) cout << i << " ";
}
cout << d;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void files() {
freopen("1.in", "r", stdin);
freopen("1.out", "w", stdout);
return;
}
const int MXN = 1e5 + 5;
const long long MOD = 1e9 + 7;
void sol() {
int n, k;
scanf("%d %d", &n, &k);
int a, b, c, d;
scanf("%d %d %d %d", &a, &b, &c, &d);
if (n == 4 || k <= n) {
printf("%d\n", -1);
return;
}
vector<int> chain;
for (int i = 1; i <= n; ++i) {
if (i != a && i != b && i != c && i != d) {
chain.push_back(i);
}
}
printf("%d %d %d %d ", a, c, chain[0], d);
for (int i = 1; i < (int)chain.size(); ++i) printf("%d ", chain[i]);
printf("%d\n", b);
printf("%d %d %d %d ", c, a, chain[0], b);
reverse(chain.begin(), chain.end());
for (int i = 0; i + 1 < (int)chain.size(); ++i) printf("%d ", chain[i]);
printf("%d\n", d);
}
int main() {
int tcase = 1;
while (tcase--) {
sol();
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAX = 31;
const int LIM = 2000000;
const int MAXT = 270000;
const int P = 1000000007;
const int INF = (1 << 28);
const double EPS = 1e-6;
const double PI = 3.14159265358979;
int n, k;
int a, b, c, d;
int main(void) {
scanf("%d %d", &n, &k);
scanf("%d %d %d %d", &a, &b, &c, &d);
if (n == 4 || k <= n) {
printf("-1\n");
return 0;
}
vector<int> path;
path.push_back(a);
path.push_back(c);
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) {
path.push_back(i);
}
}
path.push_back(d);
path.push_back(b);
for (int i = 0; i < n; i++) {
if (i) printf(" ");
printf("%d", path[i]);
}
cout << endl;
swap(path[0], path[1]);
swap(path[n - 2], path[n - 1]);
for (int i = 0; i < n; i++) {
if (i) printf(" ");
printf("%d", path[i]);
}
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a[654321];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
map<int, int> mapka;
mapka[1] = a;
mapka[2] = c;
mapka[n - 1] = d;
mapka[n] = b;
set<int> st;
for (int i = 1; i <= n; ++i) st.insert(i);
st.erase(a);
st.erase(b);
st.erase(c);
st.erase(d);
if (n == 4 || k <= n) {
cout << -1;
return 0;
}
int cc = 3;
for (set<int>::iterator it = st.begin(); it != st.end(); ++it)
mapka[cc++] = *it;
for (int i = 1; i <= n; ++i) cout << mapka[i] << " ";
cout << endl;
cout << mapka[2] << " " << mapka[1] << " ";
for (int i = 3; i <= n - 2; ++i) cout << mapka[i] << " ";
cout << mapka[n] << " " << mapka[n - 1] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 2 * int(1e9);
const long long INFll = 1ll * int(1e9) * int(1e9);
const int MOD = 1000000007;
template <typename T>
ostream& operator<<(ostream& out, pair<T, T>& a) {
out << a.first << " " << a.second;
return out;
}
template <typename T>
istream& operator>>(istream& in, pair<T, T>& a) {
in >> a.first >> a.second;
return in;
}
template <typename T>
istream& operator>>(istream& in, vector<T>& a) {
for (int i = 0; i < a.size(); ++i) in >> a[i];
return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> a) {
for (int i = 0; i < a.size(); ++i)
if (i == a.size() - 1)
out << a[i];
else
out << a[i] << " ";
return out;
}
int findv(vector<int>& a, int b) {
for (int i = 0; i < a.size(); ++i)
if (a[i] == b) return i;
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
int n, k;
cin >> n >> k;
if (k == n - 1) {
cout << "-1";
return 0;
}
int a, b, c, d;
cin >> a >> b >> c >> d;
a--, b--, c--, d--;
srand(35);
vector<int> x;
for (int i = 0; i < n; ++i) x.push_back(i);
int iter = 0;
while (1) {
iter++;
if (iter == 501) break;
random_shuffle(x.begin(), x.end());
set<pair<int, int> > edges;
bool good = 1;
vector<int> p1, p2;
p1.push_back(a);
p2.push_back(c);
if (rand() % 3 == 0) {
int posa = findv(x, a);
int posb = findv(x, b);
swap(x[posa], x[0]);
swap(x[posb], x.back());
int posc = findv(x, c);
int posd = findv(x, d);
swap(x[posc], x[1]);
swap(x[posd], x[n - 2]);
}
for (int i : x)
if (i != a && i != b) {
edges.insert(make_pair(p1.back(), i));
edges.insert(make_pair(i, p1.back()));
p1.push_back(i);
}
edges.insert(make_pair(p1.back(), b));
edges.insert(make_pair(b, p1.back()));
p1.push_back(b);
for (int i : x)
if (i != c && i != d) {
edges.insert(make_pair(p2.back(), i));
edges.insert(make_pair(i, p2.back()));
p2.push_back(i);
}
edges.insert(make_pair(p2.back(), d));
edges.insert(make_pair(d, p2.back()));
p2.push_back(d);
if (edges.size() > 2 * k || edges.count(make_pair(a, b)) ||
edges.count(make_pair(c, d)))
good = 0;
if (0) cerr << edges.size() / 2 << endl;
if (good) {
for (int& i : p1) i++;
for (int& i : p2) i++;
cout << p1 << endl << p2 << endl;
return 0;
}
}
cout << -1;
if (0)
cerr << fixed << setprecision(0)
<< "TIME = " << clock() / (long double)CLOCKS_PER_SEC * 1000 << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int u[1005];
int v[1005];
int main() {
int n, k, i;
cin >> n >> k;
int a, b, c, d;
int t;
cin >> a >> b >> c >> d;
if (n == 4) {
cout << "-1" << endl;
} else if (k < n + 1) {
cout << "-1" << endl;
} else {
cout << a << " ";
cout << c << " ";
for (i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) {
continue;
}
cout << i << " ";
}
cout << d << " ";
cout << b << endl;
cout << c << " ";
cout << a << " ";
for (i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) {
continue;
}
cout << i << " ";
}
cout << b << " ";
cout << d << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int inf = 1001001001;
int n, k, a, b, c, d, p[1111111], ans;
int main() {
ios_base::sync_with_stdio(0);
cin >> n >> k >> a >> b >> c >> d;
if (n == 4) {
cout << -1;
return 0;
}
if (k < n + 1) {
cout << -1;
return 0;
}
p[a] = 1;
p[b] = 1;
p[c] = 1;
p[d] = 1;
cout << a << ' ' << c << ' ';
for (int i = 1; i <= n; i++) {
if (p[i] == 0) cout << i << ' ';
}
cout << d << ' ' << b << endl;
cout << c << ' ' << a << ' ';
for (int i = 1; i <= n; i++) {
if (p[i] == 0) cout << i << ' ';
}
cout << b << ' ' << d << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, k, a, b, c, d;
bool vis[1005];
int main() {
cin >> n >> k;
cin >> a >> b >> c >> d;
if (k <= n || n <= 4) {
cout << -1 << "\n";
return 0;
}
vis[a] = vis[b] = vis[c] = vis[d] = 1;
cout << a << " " << c << " ";
for (int i = 1; i <= n; i++)
if (!vis[i]) cout << i << " ";
cout << d << " " << b << "\n";
cout << c << " " << a << " ";
for (int i = 1; i <= n; i++)
if (!vis[i]) cout << i << " ";
cout << b << " " << d << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 5050;
int main() {
int n, k, a, b, c, d;
cin >> n >> k;
cin >> a >> b >> c >> d;
if (n >= k || n == 4)
puts("-1");
else {
cout << a << " " << c << " ";
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) {
cout << i << " ";
}
}
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) {
cout << i << " ";
}
}
cout << b << " " << d << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int a, b, c, d;
cin >> a >> b >> c >> d;
if (n >= m || n == 4)
cout << -1 << endl;
else {
cout << a << " " << c << " ";
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << " ";
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << " ";
cout << b << " " << d << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int a[1000007];
int b[1000007];
int main() {
int i;
for (i = 0; i < 2; i++) scanf("%d", a + i);
for (i = 0; i < 4; i++) scanf("%d", b + i);
if (a[0] > 4) {
if (a[1] >= a[0] + 1) {
int lt;
v.push_back(b[0]);
for (i = 1; i <= a[0]; i++)
if (i != b[0] && i != b[1] && i != b[2] && i != b[3]) {
lt = i;
break;
}
for (i = 1; i <= a[0]; i++)
if (i != b[0] && i != b[1] && i != b[2] && i != b[3] && i != lt) {
v.push_back(i);
}
v.push_back(b[2]);
v.push_back(lt);
v.push_back(b[3]);
v.push_back(b[1]);
for (i = 0; i < v.size(); i++) printf("%d ", v[i]);
printf("\n");
for (i = (int)v.size() - 4; i >= 0; i--) printf("%d ", v[i]);
printf("%d ", v[(int)v.size() - 3]);
printf("%d %d", v[(int)v.size() - 1], v[v.size() - 2]);
} else
printf("-1");
} else
printf("-1");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, k, a, b, c, d;
int main() {
ios::sync_with_stdio(0);
cin >> n >> k >> a >> b >> c >> d;
if ((a == c && b == d) || (a == d && b == c)) {
cout << a << ' ';
for (int i = 1; i <= n; i++) {
if (i != a && i != b) cout << i << ' ';
}
cout << b << '\n';
cout << c << ' ';
for (int i = 1; i <= n; i++) {
if (i != a && i != b) cout << i << ' ';
}
cout << d;
} else if ((a == c) || (a == d) || (b == c) || (b == d)) {
if (k < n) {
cout << -1;
} else {
if (a == c) {
cout << a << ' ';
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << d << ' ' << b << '\n';
cout << a << ' ';
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << b << ' ' << d;
} else if (b == d) {
cout << a << ' ' << c << ' ';
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << b << '\n';
cout << c << ' ' << a << ' ';
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << b;
} else if (a == d) {
cout << a << ' ';
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << c << ' ' << b << '\n';
cout << c << ' ' << b << ' ';
for (int i = n; i >= 1; i--)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << a;
} else {
cout << a << ' ' << d << ' ';
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << b << '\n';
cout << c << ' ';
for (int i = n; i >= 1; i--)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << a << ' ' << d;
}
}
} else if (k < n + 1 || n == 4) {
cout << -1;
} else {
cout << a << ' ' << c << ' ';
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << d << ' ' << b << '\n';
cout << c << ' ' << a << ' ';
for (int i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << b << ' ' << d;
}
}
|
#include <bits/stdc++.h>
int n, k, a, b, c, d;
std::vector<int> first_path;
std::vector<int> second_path;
bool first_reversed = false;
bool second_reversed = false;
bool failed = false;
void read() {
scanf("%d %d\n%d %d %d %d", &n, &k, &a, &b, &c, &d);
--a;
--b;
--c;
--d;
first_path.resize(n);
second_path.resize(n);
}
void fill_with_everything_except(std::vector<int>::iterator begin,
std::vector<int>::iterator end,
const std::vector<int> &except) {
for (int i = 0; begin != end; ++begin, ++i) {
while (find(except.begin(), except.end(), i) != except.end()) {
++i;
}
*begin = i;
}
}
void solve() {
if (a > b) {
std::swap(a, b);
first_reversed = true;
}
if (c > d) {
std::swap(c, d);
second_reversed = true;
}
first_path[0] = a;
first_path[n - 1] = b;
if (a == c && b == d) {
fill_with_everything_except(next(begin(first_path)), prev(end(first_path)),
std::vector<int>{a, b});
copy(begin(first_path), end(first_path), begin(second_path));
} else {
if (k < n) {
failed = true;
return;
}
if (a == c) {
fill_with_everything_except(next(begin(first_path)),
prev(prev(end(first_path))),
std::vector<int>{a, b, d});
first_path[n - 2] = d;
copy(begin(first_path), end(first_path), begin(second_path));
std::swap(second_path[n - 1], second_path[n - 2]);
} else if (b == d) {
fill_with_everything_except(next(next(begin(first_path))),
prev(end(first_path)),
std::vector<int>{a, b, c});
first_path[1] = c;
copy(begin(first_path), end(first_path), begin(second_path));
std::swap(second_path[0], second_path[1]);
} else {
if (k < n + 1 || n == 4) {
failed = true;
return;
}
fill_with_everything_except(next(next(begin(first_path))),
prev(prev(end(first_path))),
std::vector<int>{a, b, c, d});
first_path[1] = c;
first_path[n - 2] = d;
copy(begin(first_path), end(first_path), begin(second_path));
std::swap(second_path[0], second_path[1]);
std::swap(second_path[n - 1], second_path[n - 2]);
}
}
if (first_reversed) {
reverse(begin(first_path), end(first_path));
}
if (second_reversed) {
reverse(begin(second_path), end(second_path));
}
}
void print() {
if (failed) {
printf("-1\n");
} else {
for (int i = 0; i < n; ++i) {
printf("%d ", first_path[i] + 1);
}
printf("\n");
for (int i = 0; i < n; ++i) {
printf("%d ", second_path[i] + 1);
}
}
}
int main() {
read();
solve();
print();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
short a, b, c, d, n, k;
cin >> n >> k >> a >> b >> c >> d;
if (k < n + 1) {
cout << -1;
return 0;
}
if (n == 4) {
cout << -1;
return 0;
}
cout << a << " " << c;
for (short i = 1; i <= n; ++i) {
if (i == a || i == b || i == c || i == d) {
continue;
}
cout << " " << i;
}
cout << " " << d << " " << b << endl;
cout << c << " " << a;
for (short i = 1; i <= n; ++i) {
if (i == a || i == b || i == c || i == d) {
continue;
}
cout << " " << i;
}
cout << " " << b << " " << d;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, c, d, i;
int main() {
scanf("%d%d %d%d%d%d", &n, &m, &a, &b, &c, &d);
if (n == 4 || m < n + 1) return 0 * puts("-1");
printf("%d %d ", a, c);
for (i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d %d\n", d, b);
printf("%d %d ", c, a);
for (i = n; i; i--)
if (i != a && i != b && i != c && i != d) printf("%d ", i);
printf("%d %d\n", b, d);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if (n == 4) {
cout << "-1" << endl;
return 0;
}
int a, b, c, d;
cin >> a >> b >> c >> d;
if (k < n + 1) return cout << "-1" << endl, 0;
vector<int> v;
for (int i = 1; i <= n; ++i) {
if (i != a && i != b && i != c && i != d) v.push_back(i);
}
cout << a << ' ' << c << ' ';
for (int i = 0; i < v.size(); ++i) cout << v[i] << ' ';
cout << d << ' ' << b << endl;
cout << c << ' ' << a << ' ';
for (int i = 0; i < v.size(); ++i) cout << v[i] << ' ';
cout << b << ' ' << d << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
unsigned long long mod = 1e9 + 7;
unsigned long long ncr(long long n, long long k) {
unsigned long long res = 1;
if (k > n - k) k = n - k;
for (long long i = 0; i < k; ++i) {
res *= (n - i);
res /= (i + 1);
res = res;
}
return res;
}
bool prime(unsigned long long num) {
bool flag = true;
for (unsigned long long i = 2; i * i <= num; i++) {
if (num % i == 0) {
flag = false;
break;
}
}
return flag;
}
long long ipow(long long base, long long exp) {
long long result = 1;
for (;;) {
if (exp & 1) {
result *= base;
result = result % mod;
}
exp >>= 1;
if (!exp) break;
base *= base;
base = base % mod;
}
return result % mod;
}
long long abs(long long a, long long b) {
if ((a - b) > 0)
return (a - b);
else
return (b - a);
}
long long MOD = 998244353;
long long add(long long a, long long b) {
a += b;
if (a >= MOD) a -= MOD;
if (a < 0) a += MOD;
return a;
}
long long gcd(long long a, long long b) {
if (b == 0) return a;
return gcd(b, a % b);
}
long long der(long long k) {
long long res = 0;
long long fact = 1;
for (long long i = 2; i <= k; i++) fact *= i;
long long s = 1;
long long j = 1;
for (long long i = 2; i <= k; i++) {
j = j * i;
long long first = (fact / j) * s;
res += first;
s = s * -1;
}
return res;
}
vector<int> v[1000];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
if (k < n + 1) {
cout << "-1";
return 0;
}
int node;
if (n == 4) {
cout << "-1";
return 0;
}
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) {
continue;
}
node = i;
break;
}
if (n == 5) {
cout << a << " " << c << " " << node << " " << d << " " << b << endl;
cout << c << " " << a << " " << node << " " << b << " " << d << endl;
return 0;
}
int n1 = node, n2;
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d || i == node) {
continue;
}
v[n1].push_back(i);
n1 = i;
}
cout << a << " " << c << " ";
bool visit[n + 1];
visit[a] = true;
visit[b] = true;
n2 = node;
while (node != n1) {
cout << node << " ";
visit[node] = true;
node = v[node][0];
}
cout << n1 << " ";
cout << d << " " << b;
cout << endl;
cout << c << " " << a << " ";
while (n1 != n2) {
cout << n2 << " ";
n2 = v[n2][0];
}
cout << n1 << " ";
cout << b << " " << d;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 7;
const long long N = 2e5 + 7;
const long long MOD = 1e9 + 7;
const double Pi = 3.14159265358979323846;
signed main() {
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(20);
cerr << fixed << setprecision(11);
};
long long n, k;
cin >> n >> k;
long long a, b, c, d;
cin >> a >> b >> c >> d;
if (n == 4 || k < n + 1)
cout << -1 << '\n';
else {
cout << a << ' ' << c << ' ';
for (long long i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << d << ' ' << b << '\n';
cout << c << ' ' << a << ' ';
for (long long i = 1; i <= n; i++)
if (i != a && i != b && i != c && i != d) cout << i << ' ';
cout << b << ' ' << d << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, a, b, c, d;
cin >> n >> k;
cin >> a >> b >> c >> d;
if (n == 4 || n >= k) {
cout << -1;
} else {
cout << a << ' ' << c << ' ';
for (int i = 1; i <= n; ++i) {
if (i != a && i != b && i != c && i != d) cout << i << ' ';
}
cout << d << ' ' << b << '\n';
cout << c << ' ' << a << ' ';
for (int i = 1; i <= n; ++i) {
if (i != a && i != b && i != c && i != d) cout << i << ' ';
}
cout << b << ' ' << d << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
int vet[1010];
int ordem[1010];
int main() {
int n, k;
int a, b, c, d;
int i, j;
scanf("%d %d", &n, &k);
scanf("%d %d %d %d", &a, &b, &c, &d);
if (n < 5 || n + 1 > k) {
printf("-1\n");
return 0;
}
vet[a] = 1;
vet[b] = 1;
vet[c] = 1;
vet[d] = 1;
ordem[0] = a;
j = 1;
for (i = 1; i < n - 1; i++) {
if (i == 1) {
ordem[i] = c;
vet[c] = 1;
} else if (i == 3) {
ordem[i] = d;
vet[d] = 1;
} else {
while (vet[j]) j++;
ordem[i] = j;
vet[j]++;
j++;
}
}
ordem[i] = b;
for (i = 0; i < n; i++) {
printf("%d ", ordem[i]);
}
printf("\n");
printf("%d %d %d %d ", c, a, ordem[2], b);
for (i = n - 2; i >= 3; i--) {
printf("%d ", ordem[i]);
}
printf("\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int dir1[8][2] = {1, 2, 2, 1, 2, -1, 1, -2, -1, 2, -2, 1, -1, -2, -2, -1};
int dir2[4][2] = {1, 0, 0, 1, -1, 0, 0, -1};
int dir3[8][2] = {1, 0, 0, 1, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1};
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
bool Isleap(int year) {
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) return true;
return false;
}
bool isPrime(int x) {
if (x == 1)
return false;
else if (x == 2)
return true;
for (int i = 2; i <= sqrt(x * 1.0); ++i) {
if (x % i == 0) return false;
}
return true;
}
vector<int> vt;
int main() {
int n, k, a, b, c, d;
while (~scanf("%d %d %d %d %d %d", &n, &k, &a, &b, &c, &d)) {
vt.clear();
if (n == 4 || k < n + 1) {
printf("-1\n");
continue;
}
for (int i = 1; i <= n; ++i) {
if (i != a && i != b && i != c && i != d) vt.push_back(i);
}
printf("%d %d", a, c);
for (int i = 0; i < vt.size(); ++i) printf(" %d", vt[i]);
printf(" %d %d\n", d, b);
printf("%d %d", c, a);
for (int i = 0; i < vt.size(); ++i) printf(" %d", vt[i]);
printf(" %d %d\n", b, d);
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:512000000")
using namespace std;
void solve();
void precalc();
clock_t start;
int testNumber = 1;
bool todo = true;
int main() {
start = clock();
int t = 1;
cout.sync_with_stdio(0);
cin.tie(0);
precalc();
cout.precision(10);
cout << fixed;
int testNum = 1;
while (t--) {
solve();
++testNumber;
}
return 0;
}
template <typename T>
T binpow(T q, T w, T mod) {
if (!w) return 1 % mod;
if (w & 1) return q * 1LL * binpow(q, w - 1, mod) % mod;
return binpow(q * 1LL * q % mod, w / 2, mod);
}
void precalc() {}
template <typename T>
T gcd(T q, T w) {
while (w) {
q %= w;
swap(q, w);
}
return q;
}
template <typename T>
T lcm(T q, T w) {
return q / gcd(q, w) * w;
}
void solve() {
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
--a;
--b;
--c;
--d;
if (n == 4) {
cout << "-1\n";
return;
}
if (k < n + 1) {
cout << "-1\n";
return;
}
vector<int> res(n, -1);
res[0] = a;
res[n - 1] = b;
res[1] = c;
res[3] = d;
int last = 0;
for (int i = 0; i < n; ++i) {
if (res[i] == -1) {
while (last == a || last == b || last == c || last == d) {
++last;
}
res[i] = last++;
}
}
for (int i = 0; i < n; ++i) {
cout << res[i] + 1 << ' ';
}
cout << "\n";
cout << res[1] + 1 << ' ' << res[0] + 1 << ' ' << res[2] + 1 << ' ';
for (int i = n - 1; i > 2; --i) {
cout << res[i] + 1 << ' ';
}
}
|
#include <bits/stdc++.h>
using namespace std;
priority_queue<long long int, vector<long long int>, greater<long long int> > q;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int n, k, a, b, c, d;
cin >> n >> k >> a >> b >> c >> d;
if (k < n + 1 || n <= 4) {
cout << -1 << endl;
exit(0);
}
cout << a << " " << c << " ";
for (long long int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) {
cout << i << " ";
}
}
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (long long int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) {
cout << i << " ";
}
}
cout << b << " " << d << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
if (m < n + 1 || n <= 4) {
cout << -1;
return 0;
}
int a, b, c, d;
cin >> a >> b >> c >> d;
unordered_set<int> s;
s.insert(a);
s.insert(b);
s.insert(c);
s.insert(d);
vector<int> ans;
ans.push_back(a);
ans.push_back(c);
for (int i = 1; i <= n; i++)
if (s.find(i) == s.end()) ans.push_back(i);
ans.push_back(d);
ans.push_back(b);
for (auto x : ans) cout << x << " ";
cout << "\n";
int sz = ans.size();
swap(ans[0], ans[1]);
swap(ans[n - 2], ans[n - 1]);
for (auto x : ans) cout << x << " ";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0, 0, 0, 0, 0};
int dy[] = {0, 0, 1, -1, 0, 0, 0, 0};
const long long inf = 1000000007;
const double eps = 0.000000009;
long long mod = 1000000007;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n, k, a, b, c, d;
cin >> n >> k >> a >> b >> c >> d;
if (n < 5) {
cout << -1 << endl;
return 0;
}
if (k < n + 1) {
cout << -1 << endl;
return 0;
}
cout << a << " " << c << " ";
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) continue;
cout << i << " ";
}
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (int i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) continue;
cout << i << " ";
}
cout << b << " " << d << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
const int INF = INT_MAX / 2;
const int MOD = 1e9 + 7;
const int MN = 1001;
int n, k, a, b, c, d;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k >> a >> b >> c >> d;
if (n == 4)
cout << -1 << '\n';
else if (k < n + 1)
cout << -1 << '\n';
else {
vector<int> v;
for (int i = 1; i <= n; ++i) {
if (i != a && i != b && i != c && i != d) v.push_back(i);
}
cout << a << ' ' << d << ' ';
for (auto e : v) cout << e << ' ';
cout << c << ' ' << b << '\n';
cout << c << ' ' << b << ' ';
for (int i = v.size() - 1; i >= 0; --i) cout << v[i] << ' ';
cout << a << ' ' << d << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using std::abs;
using std::cerr;
using std::cin;
using std::cout;
using std::map;
using std::max;
using std::min;
using std::pair;
using std::set;
using std::string;
using std::swap;
using std::vector;
using ll = long long;
using uint = unsigned int;
using pll = pair<ll, ll>;
template <typename T>
void err(vector<string>::iterator it, T a) {
cerr << it->substr((*it)[0] == ' ') << " = " << a << '\n';
}
template <typename T, typename... Ts>
void err(vector<string>::iterator it, T a, Ts... as) {
cerr << it->substr((*it)[0] == ' ') << " = " << a << ", ";
err(++it, as...);
}
struct init {
init() {
cin.tie(0);
std::iostream::sync_with_stdio(0);
cout << std::fixed << std::setprecision(10);
cerr << std::fixed << std::setprecision(10);
using namespace std::chrono;
srand(duration_cast<nanoseconds>(
high_resolution_clock::now().time_since_epoch())
.count());
}
~init() {
cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
}
} init;
int main() {
int n, k, a, b, c, d;
cin >> n >> k >> a >> b >> c >> d;
if (k <= n) {
cout << "-1\n";
return 0;
}
if (n == 4) {
cout << "-1\n";
return 0;
}
vector<char> used(n + 1, false);
used[0] = used[a] = used[b] = used[c] = used[d] = true;
vector<int> way;
for (int i = 1; i <= n; ++i) {
if (!used[i]) way.emplace_back(i);
}
cout << a << ' ' << c << ' ';
for (int i : way) cout << i << ' ';
cout << d << ' ' << b << '\n';
cout << c << ' ' << a << ' ';
for (int i : way) cout << i << ' ';
cout << b << ' ' << d << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
if (n == 4 || (k < n + 1)) {
cout << -1;
return 0;
}
int f = 1;
while (f == a || f == b || f == c || f == d) {
f++;
}
cout << a << ' ' << c << ' ' << f << ' ' << d << ' ';
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d && i != f) {
cout << i << ' ';
}
}
cout << b << '\n';
cout << c << ' ' << a << ' ' << f << ' ' << b << ' ';
for (int i = n; i >= 1; i--) {
if (i != a && i != b && i != c && i != d && i != f) {
cout << i << ' ';
}
}
cout << d;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 10;
vector<int> g[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
int a, b, c, d;
cin >> a >> b >> c >> d;
if (n < 5 || k < (n + 1)) return puts("-1"), 0;
vector<int> v;
for (int i = 1; i <= n; ++i) {
if (i == a || i == b || i == c || i == d) continue;
v.push_back(i);
}
cout << a << " " << c << " ";
for (auto i : v) cout << i << " ";
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (auto i : v) cout << i << " ";
cout << b << " " << d;
}
|
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long vis[212345] = {0};
vector<vector<int> > v(212345);
long long d[212345] = {0};
long long pow(long long a, long long b, long long m) {
long long ans = 1;
while (b) {
if (b & 1) ans = (ans * a) % m;
b /= 2;
a = (a * a) % m;
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long n, k;
cin >> n >> k;
long long a, b, c, d;
cin >> a >> b >> c >> d;
if (n == 4 || k < n + 1)
cout << "-1\n";
else {
cout << a << " " << c << " ";
long long f = 0;
long long l = -1;
for (int i = 1; i < n + 1; i++) {
if (i == a || i == b || i == c || i == d) continue;
if (f == 0) f = i;
l = i;
cout << i << " ";
}
cout << d << " " << b << "\n";
cout << c << " " << a << " ";
for (int i = 1; i < n + 1; i++) {
if (i == a || i == b || i == c || i == d) continue;
if (f == 0) f = i;
l = i;
cout << i << " ";
}
cout << b << " " << d << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
T min(T a, T b, T c) {
return min(a, min(b, c));
}
template <class T>
T max(T a, T b, T c) {
return max(a, max(b, c));
}
int n, k, a, b, c, d, ans[5005];
int main() {
scanf("%d%d", &n, &k);
scanf("%d%d%d%d", &a, &b, &c, &d);
if (n == 4 || k < n + 1)
puts("-1");
else {
ans[1] = a;
ans[2] = c;
int i = 3;
for (int u = (1); u <= (n); ++u) {
if (u != a && u != b && u != c && u != d) {
ans[i++] = u;
}
}
ans[n - 1] = d;
ans[n] = b;
for (int i = (1); i <= (n); ++i) printf("%d ", ans[i]);
puts("");
swap(ans[1], ans[2]);
swap(ans[n - 1], ans[n]);
for (int i = (1); i <= (n); ++i) printf("%d ", ans[i]);
puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int rx[4] = {0, 0, 1, -1};
int ry[4] = {-1, 1, 0, 0};
int main() {
int n, k, a, b, u, v;
cin >> n >> k;
cin >> a >> b >> u >> v;
if (k < n + 1 || n == 4) {
cout << -1 << endl;
return 0;
}
int ind1, ind2;
vector<int> p(n + 1);
p[1] = a;
int ct = 2, i = 1;
while (ct <= n - 1) {
if (i == a || i == b) {
i++;
continue;
}
p[ct] = i;
ct++;
i++;
}
p[n] = b;
for (int i = 1; i < n - 2; i++) {
if ((p[i] == u && p[i + 1] == v) || (p[i] == v && p[i + 1] == u)) {
swap(p[i + 1], p[i + 2]);
}
}
if ((p[n - 2] == u && p[n - 1] == v) || (p[n - 2] == v && p[n - 1] == u)) {
swap(p[n - 3], p[n - 2]);
}
for (int i = 1; i <= n; i++) {
if (p[i] == u) {
ind1 = i;
}
if (p[i] == v) {
ind2 = i;
}
}
for (int i = 1; i <= n; i++) {
cout << p[i] << " ";
}
cout << endl;
if (u < v) {
int s = ind1;
while (s >= 1) {
cout << p[s] << " ";
s--;
}
s = ind1 + 1;
while (s < ind2) {
cout << p[s] << " ";
s++;
}
s = n;
while (s >= ind2) {
cout << p[s] << " ";
s--;
}
} else {
int s = ind1;
while (s <= n) {
cout << p[s] << " ";
s++;
}
s = ind1 - 1;
while (s > ind2) {
cout << p[s] << " ";
s--;
}
s = 1;
while (s <= ind2) {
cout << p[s] << " ";
s++;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if (n == 4 || k <= n) {
cout << -1 << endl;
return 0;
}
int a, b, c, d;
cin >> a >> b >> c >> d;
set<int> used;
for (int i = 1; i <= n; i++) {
used.insert(i);
}
used.erase(a);
used.erase(b);
used.erase(c);
used.erase(d);
cout << a << " " << c << " ";
for (int el : used) {
cout << el << " ";
}
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (int el : used) {
cout << el << " ";
}
cout << b << " " << d << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n, k, a, b, c, d;
bool used[4 * N];
int main() {
scanf("%d%d%d%d%d%d", &n, &k, &a, &b, &c, &d);
if (n <= 4 || n >= k) {
puts("-1");
return 0;
}
used[a] = used[b] = used[c] = used[d] = 1;
int ptr = 1, out = 4;
printf("%d %d ", a, c);
while (out <= n - 1) {
if (used[ptr]) {
ptr++;
continue;
}
printf("%d ", ptr);
out++;
ptr++;
}
printf("%d %d ", d, b);
puts("");
ptr = 1, out = 4;
printf("%d %d ", c, a);
while (out <= n - 1) {
if (used[ptr]) {
ptr++;
continue;
}
printf("%d ", ptr);
out++;
ptr++;
}
printf("%d %d ", b, d);
puts("");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool rd[1005];
vector<int> v, vv;
int main() {
int n, k, a, b, c, d, aa, bb, cc, dd;
cin >> n >> k;
cin >> a >> b >> c >> d;
rd[a] = true;
rd[b] = true;
rd[c] = true;
rd[d] = true;
aa = a, bb = b, cc = c, dd = d;
int cnt = 0;
if (aa > bb) swap(aa, bb);
if (cc > dd) swap(cc, dd);
if (aa == cc or aa == dd) cnt++;
if (bb == cc or bb == dd) cnt++;
if (n <= 4) {
cout << -1 << endl;
return 0;
}
if (cnt == 0 and k < n - 1 + 2) {
cout << -1 << endl;
return 0;
}
if (cnt == 1 and k < n) {
cout << -1 << endl;
return 0;
}
if (!cnt) {
cout << a << ' ' << c;
for (int i = 1; i <= n; i++)
if (!rd[i]) cout << ' ' << i;
cout << ' ' << d << ' ' << b << endl;
cout << c << ' ' << a;
for (int i = 1; i <= n; i++)
if (!rd[i]) cout << ' ' << i;
cout << ' ' << b << ' ' << d << endl;
return 0;
}
if (cnt == 1) {
cout << a;
if (a == c) {
for (int i = 1; i <= n; i++)
if (!rd[i]) cout << ' ' << i;
cout << ' ' << d << ' ' << b << endl;
cout << a << endl;
for (int i = 1; i <= n; i++)
if (!rd[i]) cout << ' ' << i;
cout << ' ' << b << ' ' << d << endl;
} else if (a == d) {
for (int i = 1; i <= n; i++)
if (!rd[i]) cout << ' ' << i;
cout << ' ' << c << ' ' << b << endl;
cout << c << ' ' << b;
for (int i = n; i > 0; i--)
if (!rd[i]) cout << ' ' << i;
cout << ' ' << d << endl;
} else if (b == d) {
cout << ' ' << c;
for (int i = 1; i <= n; i++)
if (!rd[i]) cout << ' ' << i;
cout << ' ' << b << endl;
cout << c << ' ' << a;
for (int i = 1; i <= n; i++)
if (!rd[i]) cout << ' ' << i;
cout << ' ' << b << endl;
} else {
cout << ' ' << d;
for (int i = 1; i <= n; i++)
if (!rd[i]) cout << ' ' << i;
cout << ' ' << b << endl;
cout << c;
for (int i = n; i > 0; i--)
if (!rd[i]) cout << ' ' << i;
cout << ' ' << a << ' ' << d;
}
} else {
cout << a;
for (int i = 1; i <= n; i++)
if (!rd[i]) cout << ' ' << i;
cout << ' ' << b << endl;
;
cout << a;
for (int i = 1; i <= n; i++)
if (!rd[i]) cout << ' ' << i;
cout << ' ' << b;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const int maxn = 1e5 + 10;
const double eps = 1e-8;
const double PI = acos(-1.0);
int main() {
int n, m, a, b, c, d;
cin >> n >> m;
cin >> a >> b >> c >> d;
if (m < n - 1 + 2 || n == 4) return puts("-1");
vector<int> v;
for (int i = 1; i <= n; i++) {
if (i != a && i != b && i != c && i != d) v.push_back(i);
}
cout << a << " " << c << " ";
for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
cout << d << " " << b << endl;
cout << c << " " << a << " ";
for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
cout << b << " " << d << endl;
return 0;
}
|
#include <bits/stdc++.h>
int n, k, a, b, c, d;
int vis[1005];
int main() {
scanf("%d%d", &n, &k);
scanf("%d%d%d%d", &a, &b, &c, &d);
vis[a] = vis[b] = vis[c] = vis[d] = 1;
if (k < n + 1 || n == 4)
printf("-1\n");
else {
printf("%d %d", a, c);
for (int i = 1; i <= n; i++) {
if (!vis[i]) printf(" %d", i);
}
printf(" %d %d\n", d, b);
printf("%d %d", c, a);
for (int i = 1; i <= n; i++) {
if (!vis[i]) printf(" %d", i);
}
printf(" %d %d\n", b, d);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int n, k, i, j, a, b, c, d;
void path() {
printf("%d %d", a, c);
for (i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) continue;
printf(" %d", i);
}
printf(" %d %d\n", d, b);
swap(a, c);
swap(b, d);
printf("%d %d", a, c);
for (i = 1; i <= n; i++) {
if (i == a || i == b || i == c || i == d) continue;
printf(" %d", i);
}
printf(" %d %d\n", d, b);
}
int main() {
cin >> n >> k;
cin >> a >> b >> c >> d;
if (n <= 4 || k <= n)
printf("-1\n");
else
path();
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.