'commit'
This commit is contained in:
21
GESP/Level4/GESP202412/1.cpp
Normal file
21
GESP/Level4/GESP202412/1.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 3010;
|
||||
int a[N];
|
||||
set<int> s;
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
a[1] = 1;
|
||||
for (int k = 2; k <= n; k++) {
|
||||
if (a[k - 1] - k > 0 && s.count(a[k - 1] - k) == 0) {
|
||||
a[k] = a[k - 1] - k;
|
||||
s.insert(a[k - 1] - k);
|
||||
} else
|
||||
a[k] = a[k - 1] + k;
|
||||
}
|
||||
sort(a + 1, a + n + 1);
|
||||
for (int i = 1; i <= n; i++)
|
||||
cout << a[i] << " ";
|
||||
return 0;
|
||||
}
|
||||
34
GESP/Level4/GESP202412/2.cpp
Normal file
34
GESP/Level4/GESP202412/2.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 110;
|
||||
string s[N];
|
||||
int main() {
|
||||
// 从文本文件中获取输入
|
||||
#ifndef ONLINE_JUDGE
|
||||
freopen("4.in", "r", stdin);
|
||||
#endif
|
||||
int T;
|
||||
cin >> T;
|
||||
while (T--) {
|
||||
int n;
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++)
|
||||
cin >> s[i];
|
||||
// 对字符串进行排序
|
||||
sort(s + 1, s + n + 1);
|
||||
// 拼接成一个长的字符串
|
||||
string t = "";
|
||||
for (int i = 1; i <= n; i++)
|
||||
t = t + s[i];
|
||||
|
||||
bool isHeFa = true;
|
||||
for (int i = 1; i < t.size(); i++) {
|
||||
if (t[i] < t[i - 1]) {
|
||||
isHeFa = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
cout << isHeFa << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
BIN
GESP/Level4/GESP202412/20241207_4.pdf
Normal file
BIN
GESP/Level4/GESP202412/20241207_4.pdf
Normal file
Binary file not shown.
10
GESP/Level4/GESP202412/4.in
Normal file
10
GESP/Level4/GESP202412/4.in
Normal file
@@ -0,0 +1,10 @@
|
||||
3
|
||||
3
|
||||
aa
|
||||
ac
|
||||
de
|
||||
2
|
||||
aac
|
||||
bc
|
||||
1
|
||||
gesp
|
||||
Reference in New Issue
Block a user