0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 19:08:47 +00:00

Compare commits

...

3 Commits

7 changed files with 165 additions and 0 deletions

52
Luogu/B3614/B3614.cpp Normal file
View File

@ -0,0 +1,52 @@
#include <iostream>
#include <stack>
using std::cin;
using std::cout;
const char endl = '\n';
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
int n;
std::stack<unsigned long long> st;
cin >> n;
while (n--) {
std::string op;
cin >> op;
if (op == "push") {
unsigned long long x;
cin >> x;
st.emplace(x);
} else if (op == "pop") {
if (st.empty()) {
cout << "Empty" << endl;
} else {
st.pop();
}
} else if (op == "query") {
if (st.empty()) {
cout << "Anguei!" << endl;
} else {
cout << st.top() << endl;
}
} else if (op == "size") {
cout << st.size() << endl;
}
}
}
return 0;
}

47
Luogu/B3647/B3647.cpp Normal file
View File

@ -0,0 +1,47 @@
#include <iostream>
#include <cstring>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 105;
int n, m, f[N][N];
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
memset(f, 0x3f, sizeof(f));
for (int i = 1, u, v, w; i <= m; i++) {
cin >> u >> v >> w;
f[u][v] = f[v][u] = w;
}
for (int i = 1; i <= n; i++) {
f[i][i] = 0;
}
for (int k = 1; k <= n; k++) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
f[i][j] = std::min(f[i][j], f[i][k] + f[k][j]);
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cout << f[i][j] << ' ';
}
cout << endl;
}
return 0;
}

View File

@ -0,0 +1,54 @@
#include <iostream>
#include <algorithm>
#include <functional>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5;
int n, m, a[N], b[N];
long long ans;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= m; i++) {
cin >> b[i];
}
std::sort(a + 1, a + 1 + n, std::greater<>());
std::sort(b + 1, b + 1 + m, std::greater<>());
int i = 1;
for (; i <= n && a[i] >= 0 && b[i] >= 0; i++) {
ans += static_cast<long long>(a[i]) * b[i];
}
std::sort(a + i, a + 1 + n);
std::sort(b + i, b + 1 + m);
for (; i <= n && a[i] < 0 && b[i] < 0; i++) {
ans += static_cast<long long>(a[i]) * b[i];
}
std::sort(a + i, a + 1 + n, std::greater<>());
std::sort(b + i, b + 1 + m, std::greater<>());
for (; i <= n; i++) {
ans += static_cast<long long>(a[i]) * b[i];
}
cout << ans << endl;
return 0;
}

BIN
NowCoder/contest/65194/A/samples/1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
NowCoder/contest/65194/A/samples/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
NowCoder/contest/65194/A/samples/2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
NowCoder/contest/65194/A/samples/2.in (Stored with Git LFS) Normal file

Binary file not shown.