Precreation contest files

This commit is contained in:
2026-02-11 11:28:23 +07:00
parent 0a8ea477bb
commit cb9f7cab30
134 changed files with 1848 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
5
ABCD
EFGHIJK
TINHOCTRE
ABCD
EFGHIJK

View File

@@ -0,0 +1,4 @@
3
34
3
30

View File

@@ -0,0 +1,3 @@
3 11
3 4 2
123 0 45

BIN
misc/chuyen-de-xau/a.out Executable file

Binary file not shown.

45
misc/chuyen-de-xau/b2.cpp Normal file
View File

@@ -0,0 +1,45 @@
#include <iostream>
using namespace std;
int segn[300];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
for (int j = 0; j < 300; j++)
segn[j] = 0;
string S;
cin >> S;
const int n = S.length();
int res1 = 0;
int res2 = 0;
int l = 0, r = 1;
int i = 0;
while (r < n) {
if (S[l] == S[r])
r++;
else {
segn[i] = r - l;
l = r;
r++;
i++;
}
}
segn[i] = r - l;
i++;
for (int k = 0; k < i; k++) {
res1 = max(res1, segn[k]);
if (segn[k + 1] == 1) {
res2 = max(res2, segn[k] + segn[k + 1] + segn[k + 2]);
}
if (k != 0 || k != n - 1) {
res2 = max(res2, segn[k] + 1);
}
}
cout << res1 << '\n';
cout << res2 << '\n';
}

28
misc/chuyen-de-xau/b3.cpp Normal file
View File

@@ -0,0 +1,28 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
freopen("B3.INP", "r", stdin);
map<string, char> hash;
int q;
cin >> q;
for (int i = 0; i < q; i++) {
string a;
cin >> a;
// cout << a;
if (hash.find(a) == hash.end()) {
hash[a] = 1;
} else {
hash[a] = 0;
}
}
for (const auto i : hash) {
if (i.second == 1)
cout << i.first << '\n';
}
}

31
misc/chuyen-de-xau/b4.cpp Normal file
View File

@@ -0,0 +1,31 @@
#include <bits/stdc++.h>
using namespace std;
string S[100];
bool check(const string &a, const string &b) {
const string ab = a + b, ba = b + a;
if (stoi(ab) < stoi(ba))
return false;
return true;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
freopen("B4.INP", "r", stdin);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
string a;
cin >> a;
S[i] = a;
}
sort(S, S + n, check);
for (int i = 0; i < n; i++) {
cout << S[i];
}
cout << '\n';
}

38
misc/chuyen-de-xau/b5.cpp Normal file
View File

@@ -0,0 +1,38 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s;
cin >> s;
vector<char> digits;
for (char c : s) {
if (isdigit(c))
digits.push_back(c);
}
int m = digits.size();
string result = "";
int pos = 0;
for (int need = 5; need > 0; need--) {
char best = '0';
int bestPos = pos;
for (int i = pos; i <= m - need; i++) {
if (digits[i] > best) {
best = digits[i];
bestPos = i;
}
}
result.push_back(best);
pos = bestPos + 1;
}
cout << result;
return 0;
}

23
misc/chuyen-de-xau/b6.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int p, k;
cin >> p >> k;
vector<int> a(p), s(p);
for (int &i : a)
cin >> i;
for (int &i : s)
cin >> i;
deque<int> stack;
for (int i = 0; i < p; i++) {
while (a[i]--) {
}
}
}

30
misc/chuyen-de-xau/b7.cpp Normal file
View File

@@ -0,0 +1,30 @@
#include <bits/stdc++.h>
using namespace std;
int counter[(int)('z' - 'a')];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string a;
cin >> a;
for (const auto i : a) {
counter[i - 'a']++;
}
int sum = 0;
for (const auto i : counter) {
sum += i;
}
int max_x = 0;
char max_c;
for (int i = 0; i < 'z' - 'a'; i++) {
if (counter[i] > max_x) {
max_x = counter[i];
max_c = 'a' + i;
}
}
cout << sum << ' ' << max_c << '\n';
}

22
misc/chuyen-de-xau/b8.cpp Normal file
View File

@@ -0,0 +1,22 @@
#include <bits/stdc++.h>
using namespace std;
string words[20];
bool checker(const string &a, const string &b) { return a.size() < b.size(); }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
freopen("b8.inp", "r", stdin);
int n = 0;
while (cin >> words[n] && n < 20)
n++;
stable_sort(words, words + n, checker);
for (int i = 0; i < n; i++) {
cout << words[i] << " ";
}
cout << '\n';
}

View File

@@ -0,0 +1 @@
acb abcde abcd abc