0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 20:28:48 +00:00

4070. [Apio2015] 雅加达的摩天楼

https://hydro.ac/d/bzoj/record/6322e67232ae6c3198cc9265
This commit is contained in:
Baoshuo Ren 2022-09-15 16:47:37 +08:00
parent f738250c11
commit fa7add2782
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
135 changed files with 496 additions and 0 deletions

94
BZOJ/4070/4070.cpp Normal file
View File

@ -0,0 +1,94 @@
#include <iostream>
#include <bitset>
#include <cmath>
#include <cstring>
#include <queue>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 30001;
int n, m, l, s, t;
std::vector<std::pair<int, short>> g[N * 101];
int dist[N * 101];
std::bitset<N * 101> vis;
int spfa() {
memset(dist, 0x3f, sizeof(dist));
std::queue<int> q;
dist[s] = 0;
q.push(s);
vis[s] = true;
while (!q.empty()) {
int u = q.front();
q.pop();
vis[u] = false;
for (auto t : g[u]) {
int v = t.first;
short w = t.second;
if (dist[v] > dist[u] + w) {
dist[v] = dist[u] + w;
if (!vis[v]) {
q.push(v);
vis[v] = true;
}
}
}
}
return dist[t] == 0x3f3f3f3f ? -1 : dist[t];
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
l = std::min(static_cast<int>(std::sqrt(n)), 100);
for (int i = 1, b, p; i <= m; i++) {
cin >> b >> p;
b++;
if (i == 1) s = b;
if (i == 2) t = b;
if (p <= l) {
g[b].emplace_back(p * n + b, 0);
} else {
for (int j = 1; b + j * p <= n; j++) {
g[b].emplace_back(b + j * p, j);
}
for (int j = 1; b - j * p > 0; j++) {
g[b].emplace_back(b - j * p, j);
}
}
}
for (int i = 1; i <= l; i++) {
for (int j = 1; j <= n; j++) {
g[i * n + j].emplace_back(j, 0);
}
for (int j = 1; j <= n - i; j++) {
g[i * n + j].emplace_back(i * n + j + i, 1);
g[i * n + j + i].emplace_back(i * n + j, 1);
}
}
cout << spfa() << endl;
return 0;
}

BIN
BZOJ/4070/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/21.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/21.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/22.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/22.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/23.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/23.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/24.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/24.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/25.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/25.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/26.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/26.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/27.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/27.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/28.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/28.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/29.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/29.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/30.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/30.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/31.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/31.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/32.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/32.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/33.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/33.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/34.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/34.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/35.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/35.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/36.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/36.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/37.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/37.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/38.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/38.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/39.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/39.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/40.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/40.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/41.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/41.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/42.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/42.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/43.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/43.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/44.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/44.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/45.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/45.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/46.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/46.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/47.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/47.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/48.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/48.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/49.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/49.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/50.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/50.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/51.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/51.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/52.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/52.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/53.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/53.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4070/data/54.in (Stored with Git LFS) Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More