feat(priority-queue): new priority-queue problem formated

This commit is contained in:
2025-10-31 12:26:22 -03:00
parent 33df64c1c0
commit 2c3cad4b3e
222 changed files with 619366 additions and 0 deletions

28
argus/src/ac.cpp Normal file
View File

@@ -0,0 +1,28 @@
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int main()
{
int N, K;
cin >> N >> K;
priority_queue<pii> pq;
vector<pair<string, int>> drugs(N);
for (int i = 0; i < N; i++)
{
cin >> drugs[i].first;
cin >> drugs[i].second;
pq.push({-drugs[i].second, -i});
}
while (K--)
{
int time = pq.top().first, i = pq.top().second;
cout << -time << " " << drugs[-i].first << endl;
pq.pop();
pq.push({time - drugs[-i].second, i});
}
return 0;
}

52
argus/src/checker.cpp Normal file
View File

@@ -0,0 +1,52 @@
#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
bool compareWords(const string& a, const string& b) {
vector<string> va, vb;
stringstream sa;
sa << a;
string cur;
while (sa >> cur)
va.push_back(cur);
stringstream sb;
sb << b;
while (sb >> cur)
vb.push_back(cur);
return (va == vb);
}
int main(int argc, char *argv[]) {
setName("compare files as sequence of tokens in lines");
registerTestlibCmd(argc, argv);
string strAnswer;
int n = 0;
while (!ans.eof()) {
std::string j = ans.readString();
if (j.empty() && ans.eof())
break;
string p = ouf.readString();
strAnswer = p;
n++;
if (!compareWords(j, p))
quitf(_wa, "%d%s lines differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(),
compress(j).c_str(), compress(p).c_str());
}
if (n == 1)
quitf(_ok, "single line: '%s'", compress(strAnswer).c_str());
quitf(_ok, "%d lines", n);
}

101
argus/src/generator.cpp Normal file
View File

@@ -0,0 +1,101 @@
#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
const int MIN_N = 1;
const int MAX_N = 3000;
const int MIN_K = 1;
const int MAX_K = 10000;
const int MIN_F = 1;
const int MAX_F = 3000;
const int rnd_test_n = 100;
template <typename T> void append(vector<T> &dest, const vector<T> &orig) {
dest.insert(dest.end(), orig.begin(), orig.end());
}
string output_tc(int n, int k, const vector<pair<string, int>> &meds) {
ostringstream oss;
oss << n << " " << k << endl;
for (int i = 0; i < n; i++) {
oss << meds[i].first << " " << meds[i].second << endl;
}
return oss.str();
}
vector<string> generate_sample_tests() {
vector<string> tests;
tests.push_back(output_tc(2, 5, {{"Paracetamol", 180}, {"Amoxicilina", 300}}));
return tests;
}
vector<string> generate_manual_tests() {
vector<string> tests;
tests.push_back(output_tc(5, 10, {{"a", 1},{"b", 1},{"c", 1},{"d", 1},{"e", 1}}));
return tests;
}
string rnd_test(int i){
int min_n = MIN_N;
int max_n = MAX_N;
if(i<rnd_test_n / 3){
max_n = 100;
}
else if(i<rnd_test_n / 2){
max_n = 1000;
}
int n = rnd.next(min_n, max_n);
int k = rnd.next(MIN_K, MAX_K);
vector<pair<string, int>> meds(n);
for (int i = 0; i < n; i++) {
meds[i].first = rnd.next("[a-zA-Z]{1,15}");
meds[i].second = rnd.next(MIN_F, MAX_F);
}
return(output_tc(n, k, meds));
}
vector<string> generate_random_tests() {
vector<string> tests;
for (int i = 0; i < rnd_test_n; i++){
tests.push_back(rnd_test(i));
}
return tests;
}
string extreme_test_1(){
int n = MAX_N;
int k = MAX_K;
vector<pair<string, int>> meds(n);
for (int i = 0; i < n; i++) {
meds[i].first = rnd.next("[a-zA-Z]{1,15}");
meds[i].second = MAX_F;
}
return(output_tc(n, k, meds));
}
vector<string> generate_extreme_tests(){
vector<string> tests;
tests.push_back(extreme_test_1());
return tests;
}
int main(int argc, char *argv[]) {
registerGen(argc, argv, 1);
vector<string> tests;
size_t test = 0;
append(tests, generate_sample_tests());
append(tests, generate_manual_tests());
append(tests, generate_random_tests());
append(tests, generate_extreme_tests());
for (const auto &t : tests) {
startTest(++test);
cout << t;
}
return 0;
}

1
argus/src/script.sh Normal file
View File

@@ -0,0 +1 @@
generator

5963
argus/src/testlib.h Normal file

File diff suppressed because it is too large Load Diff

24
argus/src/validator.cpp Normal file
View File

@@ -0,0 +1,24 @@
#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
registerValidation(argc, argv);
int n = inf.readInt(1, 3000, "n");
inf.readSpace();
int k = inf.readInt(1, 10000, "k");
inf.readEoln();
for (int i = 0; i < n; i++) {
inf.readToken("[a-zA-Z]{1,15}", "name");
inf.readSpace();
inf.readInt(1, 3000, "frequency");
inf.readEoln();
}
inf.readEof();
return 0;
}