QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#408066#6428. K Co-prime PermutationNelofus#AC ✓45ms7232kbC++201.4kb2024-05-09 17:24:442024-05-09 17:24:46

Judging History

你现在查看的是最新测评结果

  • [2024-05-09 17:24:46]
  • 评测
  • 测评结果:AC
  • 用时:45ms
  • 内存:7232kb
  • [2024-05-09 17:24:44]
  • 提交

answer

// Code by Heratino & Nelofus
// Narcissus & どうか安寧な記憶を

#include <bits/stdc++.h>
using i64 = long long;

//{{{星光闪耀
template<typename Ta, typename Tb>
inline void chkmax(Ta &a, const Tb &b) {if (a < b)	a = b;}
template<typename Ta, typename Tb>
inline void chkmin(Ta &a, const Tb &b) {if (a > b)	a = b;}
char buf[1 << 20], *P1, *P2;
inline char gc() {
	if (P1 == P2)
		P2 = (P1 = buf) + fread(buf, 1, 1 << 20, stdin);
	return P1 == P2 ? EOF : *P1++;
}
template<typename T>
inline void read(T &ans) {
	ans = 0;
	T w = 1;
	char c = gc();
	while (!isdigit(c)) {
		if (c == '-')	w = -1;
		c = gc();
	}
	while (isdigit(c)) {
		ans = (ans << 3) + (ans << 1) + (c ^ 48);
		c = gc();
	}
	ans *= w;
}
template<typename T, typename ...Ts>
void read(T &a, Ts&... other) {
	read(a);
	read(other...);
}
//}}}

void solve() {
	int n, k;
	read(n, k);
	if (k == 0) {
		std::cout << "-1" << '\n';
		return ;
	} else if (k == 1) {
		for (int i = 1; i <= n; i++)
			std::cout << i << " \n"[i == n];
	} else {
		k--;
		std::vector<int> ans;
		ans.push_back(n - k + 1);
		for (int i = 2; i < n - k + 1; i++)
			ans.push_back(i);
		for (int i = n - k + 1; i < n; i++)
			ans.push_back(i + 1);
		ans.push_back(1);
		for (int i = 0; i < n; i++)
			std::cout << ans[i] << " \n"[i == n - 1];
	}
}

int main() {
	int T = 1;
	while (T--) {
		solve();
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3572kb

input:

5 3

output:

4 2 3 5 1

result:

ok ac

Test #2:

score: 0
Accepted
time: 1ms
memory: 3740kb

input:

1 0

output:

-1

result:

ok ac

Test #3:

score: 0
Accepted
time: 34ms
memory: 7156kb

input:

1000000 3789

output:

996213 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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

result:

ok ac

Test #4:

score: 0
Accepted
time: 38ms
memory: 7232kb

input:

1000000 578768

output:

421234 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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

result:

ok ac

Test #5:

score: 0
Accepted
time: 1ms
memory: 3744kb

input:

500 1

output:

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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok ac

Test #6:

score: 0
Accepted
time: 24ms
memory: 7180kb

input:

600000 600000

output:

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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 10...

result:

ok ac

Test #7:

score: 0
Accepted
time: 18ms
memory: 3492kb

input:

600000 1

output:

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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok ac

Test #8:

score: 0
Accepted
time: 1ms
memory: 3564kb

input:

600000 0

output:

-1

result:

ok ac

Test #9:

score: 0
Accepted
time: 42ms
memory: 7156kb

input:

1000000 999997

output:

5 2 3 4 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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 10...

result:

ok ac

Test #10:

score: 0
Accepted
time: 45ms
memory: 7228kb

input:

1000000 510000

output:

490002 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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

result:

ok ac

Test #11:

score: 0
Accepted
time: 32ms
memory: 7172kb

input:

999877 23324

output:

976555 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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

result:

ok ac

Test #12:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

1 1

output:

1

result:

ok ac

Test #13:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

2 0

output:

-1

result:

ok ac

Test #14:

score: 0
Accepted
time: 0ms
memory: 3720kb

input:

2 1

output:

1 2

result:

ok ac

Test #15:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

2 2

output:

2 1

result:

ok ac