Precreation contest files
This commit is contained in:
22
misc/hsg-hp-2025/.vscode/launch.json
vendored
Normal file
22
misc/hsg-hp-2025/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug C++ (input.inp)",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/${fileBasenameNoExtension}",
|
||||
"args": ["<", "${fileBasenameNoExtension}.inp"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"preLaunchTask": "Build C++",
|
||||
"MIMode": "gdb",
|
||||
"externalConsole": false,
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty printing",
|
||||
"text": "-enable-pretty-printing"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
22
misc/hsg-hp-2025/.vscode/tasks.json
vendored
Normal file
22
misc/hsg-hp-2025/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Build C++",
|
||||
"type": "shell",
|
||||
"command": "g++",
|
||||
"args": [
|
||||
"-std=gnu++17",
|
||||
"-O2",
|
||||
"-g",
|
||||
"${file}",
|
||||
"-o",
|
||||
"${fileBasenameNoExtension}"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
misc/hsg-hp-2025/a.out
Executable file
BIN
misc/hsg-hp-2025/a.out
Executable file
Binary file not shown.
24
misc/hsg-hp-2025/cbai1.cpp
Normal file
24
misc/hsg-hp-2025/cbai1.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
string a;
|
||||
cin >> a;
|
||||
|
||||
int res = 0;
|
||||
string output = "";
|
||||
|
||||
for (int i = a.length() - 1; i >= 0; i--) {
|
||||
if ('0' <= a[i] && a[i] <= '9')
|
||||
res += (int)(a[i] - '0');
|
||||
else
|
||||
output += a[i];
|
||||
}
|
||||
|
||||
cout << res << '\n';
|
||||
if (output == "")
|
||||
cout << -1 << '\n';
|
||||
else
|
||||
cout << output << '\n';
|
||||
}
|
||||
50
misc/hsg-hp-2025/cbai2.cpp
Normal file
50
misc/hsg-hp-2025/cbai2.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int max_n = 1e7;
|
||||
|
||||
char is_prime[max_n + 1];
|
||||
void sieve() {
|
||||
for (int i = 0; i <= max_n; i++)
|
||||
is_prime[i] = 1;
|
||||
is_prime[0] = 0;
|
||||
is_prime[1] = 0;
|
||||
|
||||
// 2 check
|
||||
for (int i = 4; i <= max_n; i += 2)
|
||||
is_prime[i] = 0;
|
||||
|
||||
// other
|
||||
for (int i = 3; i * i <= max_n; i += 2)
|
||||
if (is_prime[i])
|
||||
for (int j = i * i; j <= max_n; j += i)
|
||||
is_prime[j] = 0;
|
||||
}
|
||||
|
||||
int solve() {
|
||||
int n;
|
||||
cin >> n;
|
||||
if (!is_prime[n])
|
||||
return 0;
|
||||
|
||||
int digit_sum = 0;
|
||||
while (n) {
|
||||
digit_sum += n % 10;
|
||||
n /= 10;
|
||||
}
|
||||
if (!is_prime[digit_sum])
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main() {
|
||||
sieve();
|
||||
int q;
|
||||
cin >> q;
|
||||
int res = 0;
|
||||
while (q--) {
|
||||
res += solve();
|
||||
}
|
||||
cout << res << "\n";
|
||||
}
|
||||
2
misc/hsg-hp-2025/cbai2.inp
Normal file
2
misc/hsg-hp-2025/cbai2.inp
Normal file
@@ -0,0 +1,2 @@
|
||||
6
|
||||
2 3 19 23 29 17
|
||||
28
misc/hsg-hp-2025/cbai3.cpp
Normal file
28
misc/hsg-hp-2025/cbai3.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
int a[1000000];
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int m, n, S;
|
||||
cin >> m >> n >> S;
|
||||
for (int i = 0; i < m * n; i++)
|
||||
cin >> a[i];
|
||||
|
||||
sort(a, a + m * n);
|
||||
|
||||
int l = 0, r = m * n - 1;
|
||||
int cur_max = -1;
|
||||
while (l < r) {
|
||||
if (a[l] + a[r] > S)
|
||||
r--;
|
||||
else {
|
||||
cur_max = max(cur_max, a[l] + a[r]);
|
||||
l++;
|
||||
}
|
||||
}
|
||||
cout << cur_max << '\n';
|
||||
}
|
||||
4
misc/hsg-hp-2025/cbai3.inp
Normal file
4
misc/hsg-hp-2025/cbai3.inp
Normal file
@@ -0,0 +1,4 @@
|
||||
3 4 10
|
||||
6 7 8 9
|
||||
5 6 7 8
|
||||
9 8 8 7
|
||||
BIN
misc/hsg-hp-2025/cbai4
Executable file
BIN
misc/hsg-hp-2025/cbai4
Executable file
Binary file not shown.
56
misc/hsg-hp-2025/cbai4.cpp
Normal file
56
misc/hsg-hp-2025/cbai4.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void solve() {
|
||||
vector<deque<int>> char_pos(26);
|
||||
|
||||
int n, q;
|
||||
string S;
|
||||
cin >> n >> q >> S;
|
||||
|
||||
vector<int> is_exist(n, 1);
|
||||
set<int> exist_char;
|
||||
|
||||
// O(n)
|
||||
for (int i = 0; i < n; i++) {
|
||||
char_pos[S[i] - 'A'].push_back(i);
|
||||
}
|
||||
|
||||
// O(1)
|
||||
for (int i = 0; i < 26; i++)
|
||||
if (!char_pos[i].empty())
|
||||
exist_char.insert(i);
|
||||
|
||||
while (q--) {
|
||||
if (exist_char.empty())
|
||||
break;
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
int target_char;
|
||||
if (t == 0)
|
||||
target_char = *exist_char.begin();
|
||||
else
|
||||
target_char = *exist_char.rbegin();
|
||||
|
||||
int target_idx = char_pos[target_char].front();
|
||||
char_pos[target_char].pop_front();
|
||||
is_exist[target_idx] = 0;
|
||||
|
||||
if (char_pos[target_char].empty())
|
||||
exist_char.erase(target_char);
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
if (is_exist[i])
|
||||
cout << S[i];
|
||||
cout << '\n';
|
||||
}
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
solve();
|
||||
}
|
||||
3
misc/hsg-hp-2025/cbai4.inp
Normal file
3
misc/hsg-hp-2025/cbai4.inp
Normal file
@@ -0,0 +1,3 @@
|
||||
10 4
|
||||
ADBAACDABC
|
||||
0 1 1 0
|
||||
Reference in New Issue
Block a user