mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 20:08:47 +00:00
Compare commits
3 Commits
e5e1f30e37
...
44bb4f9b65
Author | SHA1 | Date | |
---|---|---|---|
44bb4f9b65 | |||
53ab5698c1 | |||
669a58d868 |
73
S2OJ/1975/1975.cpp
Normal file
73
S2OJ/1975/1975.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 55;
|
||||
|
||||
int n, m, k, dist[N << 6];
|
||||
std::vector<std::pair<int, int>> g[N << 6];
|
||||
bool vis[N << 6];
|
||||
|
||||
void dijkstra() {
|
||||
memset(dist, 0x3f, sizeof(dist));
|
||||
|
||||
std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>> q;
|
||||
|
||||
q.push(std::make_pair(0, 1));
|
||||
dist[1] = 0;
|
||||
|
||||
while (!q.empty()) {
|
||||
auto t = q.top();
|
||||
q.pop();
|
||||
|
||||
if (vis[t.second]) continue;
|
||||
|
||||
for (auto e : g[t.second]) {
|
||||
int v = e.first,
|
||||
w = e.second;
|
||||
|
||||
if (dist[v] > t.first + w) {
|
||||
dist[v] = t.first + w;
|
||||
|
||||
q.push(std::make_pair(dist[v], v));
|
||||
}
|
||||
}
|
||||
|
||||
vis[t.second] = true;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
|
||||
cin >> n >> m >> k;
|
||||
|
||||
for (int i = 1, u, v, w; i <= m; i++) {
|
||||
cin >> u >> v >> w;
|
||||
|
||||
g[u].push_back(std::make_pair(v, w));
|
||||
g[v].push_back(std::make_pair(u, w));
|
||||
|
||||
for (int j = 1; j <= k; j++) {
|
||||
g[u + (j - 1) * n].push_back(std::make_pair(v + j * n, w >> 1));
|
||||
g[v + (j - 1) * n].push_back(std::make_pair(u + j * n, w >> 1));
|
||||
g[u + j * n].push_back(std::make_pair(v + j * n, w));
|
||||
g[v + j * n].push_back(std::make_pair(u + j * n, w));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i <= k; i++) {
|
||||
g[i * n].push_back(std::make_pair(i * n + n, 0));
|
||||
}
|
||||
|
||||
dijkstra();
|
||||
|
||||
cout << dist[n * k + n] << endl;
|
||||
|
||||
return 0;
|
||||
}
|
74
S2OJ/1976/1976.cpp
Normal file
74
S2OJ/1976/1976.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1e4 + 5;
|
||||
|
||||
int n, m, k, dist[N << 5];
|
||||
std::vector<std::pair<int, int>> g[N << 5];
|
||||
bool vis[N << 5];
|
||||
|
||||
void dijkstra() {
|
||||
memset(dist, 0x3f, sizeof(dist));
|
||||
|
||||
std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>> q;
|
||||
|
||||
q.push(std::make_pair(0, 1));
|
||||
dist[1] = 0;
|
||||
|
||||
while (!q.empty()) {
|
||||
auto t = q.top();
|
||||
q.pop();
|
||||
|
||||
if (vis[t.second]) continue;
|
||||
|
||||
for (auto e : g[t.second]) {
|
||||
int v = e.first,
|
||||
w = e.second;
|
||||
|
||||
if (dist[v] > t.first + w) {
|
||||
dist[v] = t.first + w;
|
||||
|
||||
q.push(std::make_pair(dist[v], v));
|
||||
}
|
||||
}
|
||||
|
||||
vis[t.second] = true;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
|
||||
cin >> n >> m >> k;
|
||||
|
||||
for (int i = 1, u, v, w; i <= m; i++) {
|
||||
cin >> u >> v >> w;
|
||||
|
||||
g[u].push_back(std::make_pair(v, w));
|
||||
g[v].push_back(std::make_pair(u, w));
|
||||
|
||||
for (int j = 1; j <= k; j++) {
|
||||
g[u + (j - 1) * n].push_back(std::make_pair(v + j * n, 0));
|
||||
g[v + (j - 1) * n].push_back(std::make_pair(u + j * n, 0));
|
||||
|
||||
g[u + j * n].push_back(std::make_pair(v + j * n, w));
|
||||
g[v + j * n].push_back(std::make_pair(u + j * n, w));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i <= k; i++) {
|
||||
g[i * n].push_back(std::make_pair(i * n + n, 0));
|
||||
}
|
||||
|
||||
dijkstra();
|
||||
|
||||
cout << dist[n * k + n] << endl;
|
||||
|
||||
return 0;
|
||||
}
|
54
S2OJ/1982/1982.cpp
Normal file
54
S2OJ/1982/1982.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
void solve() {
|
||||
int n, m, q;
|
||||
|
||||
cin >> n >> m >> q;
|
||||
|
||||
std::vector<std::pair<int, int>> g(n + 1), h(m + 1);
|
||||
|
||||
for (int i = 1, op, x, c; i <= q; i++) {
|
||||
cin >> op >> x >> c;
|
||||
|
||||
if (op == 0) {
|
||||
g[x] = std::make_pair(c, i);
|
||||
} else { // op == 1
|
||||
h[x] = std::make_pair(c, i);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 1; j <= m; j++) {
|
||||
if (g[i].second > h[j].second) {
|
||||
cout << g[i].first;
|
||||
} else {
|
||||
cout << h[j].first;
|
||||
}
|
||||
|
||||
if (j < m) {
|
||||
cout << ' ';
|
||||
} else { // j == m
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(0);
|
||||
|
||||
int t;
|
||||
|
||||
cin >> t;
|
||||
|
||||
while (t--) solve();
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/1982/data/ex_paint1.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/ex_paint1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/ex_paint1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/ex_paint1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/ex_paint2.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/ex_paint2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/ex_paint2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/ex_paint2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint1.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint10.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint10.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint11.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint11.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint11.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint12.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint12.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint12.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint13.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint13.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint13.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint14.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint14.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint14.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint15.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint15.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint15.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint16.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint16.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint16.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint16.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint17.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint17.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint17.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint17.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint18.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint18.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint18.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint18.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint19.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint19.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint19.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint19.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint2.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint20.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint20.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint20.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint20.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint3.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint3.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint4.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint4.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint5.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint5.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint6.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint6.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint7.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint7.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint8.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint8.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint9.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint9.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/paint9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/paint9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1982/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1982/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user