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,18 @@
2
2
5
-> 4 3
<- 15
<- 4
-> 3 1
-> 1 3
1
8
-> 1 1
-> 1 2
-> 2 1
-> 2 2
<- 1
<- 2
<- 3
<- 4

View File

@@ -0,0 +1,13 @@
7
2 3
1 2
9
13
1
4
3
2
1 1
2 2
2 1
1 2

View File

@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;
struct {
}
void solve() {
int q;
cin >> q;
}
int main() {
int t;
cin >> t;
while (t--)
solve();
}

Binary file not shown.

View File

@@ -0,0 +1,6 @@
5
2
4
5
7
100

View File

@@ -0,0 +1,5 @@
Alice
Bob
Alice
Alice
Bob

View File

@@ -0,0 +1,16 @@
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
if (!(n & ((1 << 2) - 1)))
cout << "Bob\n";
else
cout << "Alice\n";
}
}

Binary file not shown.

View File

@@ -0,0 +1,7 @@
3
5 2 3
3 2 4 4 1
5 4 1
5 3 4 5 2
6 1 1
1 2 3 4 5 6

View File

@@ -0,0 +1,3 @@
YES
YES
NO

View File

@@ -0,0 +1,30 @@
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
void solve() {
int n, j, k;
cin >> n >> j >> k;
vector<int> a(n);
for (auto &i : a)
cin >> i;
if (a[j - 1] == *max_element(a.begin(), a.end())) {
cout << "YES\n";
return;
}
if (k >= 2)
cout << "YES\n";
else
cout << "NO\n";
}
int main() {
int t;
cin >> t;
while (t--)
solve();
}

View File

@@ -0,0 +1,7 @@
3
6
1 3 5 4 7 2
4
13 10 12 20
7
1 2 3 4 5 6 7

View File

@@ -0,0 +1,3 @@
100011
1101
1000001

View File

@@ -0,0 +1,40 @@
#include <iostream>
#include <vector>
using namespace std;
void min_maxer(vector<int> &_a, vector<int> &pre, vector<int> &stu,
vector<bool> &map) {
int n = _a.size();
map[0] = true;
map[n - 1] = true;
for (int i = 1; i < n; i++) {
if (_a[i] < _a[i - 1])
map[i] = true;
if (_a[n - i - 1] < _a[n - i - 2])
map[i] = true;
}
}
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (auto &i : a)
cin >> i;
vector<int> min_prefix(n), max_stufix(n);
vector<bool> map(n);
min_maxer(a, min_prefix, max_stufix, map);
for (auto i : map)
cout << i;
cout << "\n";
}
int main() {
int t;
cin >> t;
while (t--)
solve();
}

View File

@@ -0,0 +1,11 @@
5
5
1 0 0 1 2
6
3 2 0 4 5 1
6
1 2 0 1 3 2
4
0 3 4 1
5
0 0 0 0 0

View File

@@ -0,0 +1,5 @@
1 2 4 3 2 1
1 6 5 4 3 2 1
1 3 5 4 3 2 1
1 3 3 2 1
1 1 1 1 1 1

View File

@@ -0,0 +1,31 @@
#include "iostream"
#include <map>
using namespace std;
void solve() {
int n, x;
cin >> n;
map<int, int> hash_map;
for (int i = 0; i < n; i++) {
cin >> x;
if (hash_map.count(x) == 0)
hash_map[x] = 1;
else
hash_map[x]++;
}
for (int k = 0; k <= n; k++) {
int cur_mex = 0;
for (auto &i : hash_map) {
}
}
}
int main() {
int t;
cin >> t;
while (t--)
solve();
}

Binary file not shown.

View File

@@ -0,0 +1,8 @@
7
1 4 1 2
1 5 2 1
3 2 2 1
1 3 2 1
2 1 1 2
3 1 1 2
1 100 10000000 10000000

View File

@@ -0,0 +1,7 @@
3
6
1
3
-1
-1
990000000

View File

@@ -0,0 +1,43 @@
#include <iostream>
using namespace std;
void solve() {
int a, b, x, y;
cin >> a >> b >> x >> y;
if (a > b) {
if (a - b == 1) {
if (a % 2 != 0) {
cout << y << endl;
return;
}
}
cout << "-1\n";
return;
}
int diff = b - a;
int xdiff = diff * x;
if (diff % 2 == 0) {
cout << min(xdiff, ((diff * x) / 2) + ((diff * y) / 2)) << endl;
return;
} else {
if (a % 2 != 0) {
cout << min(xdiff, (diff / 2 + 1) * x + (diff / 2) * y) << endl;
return;
} else {
cout << min(xdiff, (diff / 2) * x + (diff / 2 + 1) * y) << endl;
return;
}
}
}
int main() {
int t;
cin >> t;
while (t--)
solve();
}

Binary file not shown.

View File

@@ -0,0 +1,6 @@
5
6
96
78
122
696

View File

@@ -0,0 +1,5 @@
6
6
7
1
6

View File

@@ -0,0 +1,20 @@
#include <iostream>
#include <string>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int x;
cin >> x;
string xstr = to_string(x);
int res = 10;
for (const char &i : xstr) {
res = min(res, (int)(i - '0'));
}
cout << res << endl;
}
}

View File

@@ -0,0 +1,11 @@
5
5 1
0 1 0 0 0
7 3
0 0 0 0 0 0 0
3 1
1 1 1
4 2
0 1 0 1
6 2
0 0 1 0 0 0

View File

@@ -0,0 +1,5 @@
3
2
0
0
2

View File

@@ -0,0 +1,38 @@
#include <iostream>
#include <vector>
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int &i : a)
cin >> i;
int res = 0;
int len = 0;
for (int i = 0; i < n; i++) {
if (len == k) {
len = 0;
res++;
continue;
}
if (a[i] == 0) {
len++;
}
if (a[i] == 1) {
len = 0;
}
}
if (len == k)
res++;
cout << res << endl;
}
int main() {
int t;
cin >> t;
while (t--)
solve();
}

View File

@@ -0,0 +1,11 @@
5
5 3
3 2 1 4 5
3 1
1 3 4
4 4
4 4 4 2
6 2
2 3 6 9 1 2
4 2
1 2 5 6

View File

@@ -0,0 +1,5 @@
YES
NO
YES
YES
NO

View File

@@ -0,0 +1,37 @@
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (auto &i : a)
cin >> i;
int h = a[k - 1];
sort(a.begin(), a.end());
int time = 0;
for (auto H : a) {
if (H <= h)
continue;
time += H - h;
if (time > h) {
cout << "NO\n";
return;
}
h = H;
}
cout << "YES\n";
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
}

Binary file not shown.

View File

@@ -0,0 +1,16 @@
5
6
72 24 3 3 3 3
3 3 3 6 12 144
3
1 2 3
4 5 6
5
125 125 125 25 25
25 25 25 25 75
4
123 421 282 251
125 1981 239 223
3
124 521 125
125 121 121

View File

@@ -0,0 +1,5 @@
YES
NO
YES
NO
NO

View File

@@ -0,0 +1,48 @@
#include <iostream>
#include <vector>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> pre(n), stu(n);
for (int &i : pre)
cin >> i;
for (int &i : stu)
cin >> i;
if (pre[n - 1] != stu[0]) {
cout << "NO\n";
return;
}
for (int i = 0; i < n - 1; i++) {
if (pre[i] < pre[i + 1]) {
cout << "NO\n";
return;
}
if (pre[i] % pre[i + 1] != 0) {
cout << "NO\n";
return;
}
}
for (int i = n - 1; i > 0; i--) {
if (stu[i] < stu[i - 1]) {
cout << "NO\n";
return;
}
if (stu[i] % stu[i - 1] != 0) {
cout << "NO\n";
return;
}
}
cout << "YES\n";
}
int main() {
int t;
cin >> t;
while (t--)
solve();
}

View File

@@ -0,0 +1,27 @@
#include <iostream>
#include <vector>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (int &i : a)
cin >> i;
for (int i = 0; i < n - 1; i++) {
if (a[i] > a[i + 1]) {
cout << "YES\n2\n";
cout << a[i] << " " << a[i + 1] << "\n";
return;
}
}
cout << "NO\n";
}
int main() {
int t;
cin >> t;
while (t--)
solve();
}

View File

@@ -0,0 +1,7 @@
3
2
1 2
3
1 2 3
4
3 0 2 3

View File

@@ -0,0 +1,22 @@
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (auto &i : a)
cin >> i;
cout << min(a[0] + a[1], 2 * a[0]) << "\n";
}
int main() {
int t;
cin >> t;
while (t--)
solve();
}

View File

@@ -0,0 +1,14 @@
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
cout << 2 * n << '\n';
}
}

Binary file not shown.

View File

@@ -0,0 +1,11 @@
5
4
2 3 5 7
4
115 9 2 28
5
8 4 1 6 2
6
1 5 4 1 4 7
2
100000 100000

View File

@@ -0,0 +1,5 @@
YES
NO
NO
YES
YES

View File

@@ -0,0 +1,55 @@
#include <iostream>
using namespace std;
int a[200];
bool check(int a, int b, int c) {
if (a + b <= c)
return false;
if (a + c <= b)
return false;
if (b + c <= a)
return false;
return true;
}
void run() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
if (n == 2) {
if (check(a[0], a[0], a[1]) || check(a[0], a[1], a[1])) {
cout << "YES\n";
} else {
cout << "NO\n";
}
return;
}
for (int i = 0; i < n - 2; i++) {
if (check(a[i], a[i + 1], a[i + 2])) {
cout << "YES\n";
return;
}
}
for (int i = 0; i < n - 1; i++) {
if (check(a[i], a[i], a[i + 1]) || check(a[i], a[i + 1], a[i + 1])) {
cout << "YES\n";
return;
}
}
cout << "NO\n";
}
int main() {
int t;
cin >> t;
while (t--) {
run();
};
}