0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

#2632. 「BalticOI 2011 Day1」打开灯泡 Switch the Lamp On

https://loj.ac/s/1629106
This commit is contained in:
Baoshuo Ren 2022-11-10 21:08:21 +08:00
parent 035b647bb8
commit de099e673b
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
108 changed files with 397 additions and 0 deletions

76
LibreOJ/2632/2632.cpp Normal file
View File

@ -0,0 +1,76 @@
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 505;
const int INF = 0x3f3f3f3f;
int n, m, dist[N * N];
std::vector<std::pair<int, int>> g[N * N];
bool vis[N * N];
int id(int x, int y) {
return x * (m + 1) + y;
}
void dijkstra() {
std::fill_n(dist, N * N, INF);
std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>> q;
q.emplace(0, id(0, 0));
dist[id(0, 0)] = 0;
while (!q.empty()) {
int u = q.top().second;
q.pop();
if (vis[u]) continue;
vis[u] = true;
for (auto e : g[u]) {
int v = e.first,
w = e.second;
if (dist[v] > dist[u] + w) {
dist[v] = dist[u] + w;
q.emplace(dist[v], v);
}
}
}
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
char c;
cin >> c;
g[id(i, j)].emplace_back(id(i - 1, j - 1), c != '\\');
g[id(i - 1, j - 1)].emplace_back(id(i, j), c != '\\');
g[id(i, j - 1)].emplace_back(id(i - 1, j), c != '/');
g[id(i - 1, j)].emplace_back(id(i, j - 1), c != '/');
}
}
dijkstra();
if (dist[id(n, m)] == INF) {
cout << "NO SOLUTION" << endl;
} else {
cout << dist[id(n, m)] << endl;
}
return 0;
}

BIN
LibreOJ/2632/data/lamp-testdata.txt (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g01A.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g01A.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02A.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02A.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02B.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02B.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02C.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02C.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02D.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02D.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02E.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02E.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02F.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02F.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02G.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02G.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02H.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g02H.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g03A.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g03A.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g03B.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g03B.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g03C.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g03C.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g03D.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g03D.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g04A.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g04A.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g04B.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g04B.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g04C.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g04C.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g04D.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g04D.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g05A.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g05A.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g05B.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g05B.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g05C.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g05C.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g05D.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g05D.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g06A.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g06A.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g06B.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g06B.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g06C.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g06C.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g06D.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g06D.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g07A.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g07A.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g07B.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g07B.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g07C.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g07C.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g07D.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g07D.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g08A.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g08A.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g08B.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g08B.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g08C.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g08C.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g08D.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g08D.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g09A.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g09A.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g09B.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g09B.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g09C.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g09C.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g09D.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g09D.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g10A.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g10A.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g10B.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g10B.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g10C.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g10C.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g10D.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g10D.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g11A.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g11A.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g11B.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g11B.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g11C.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g11C.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g11D.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g11D.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g12A.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g12A.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g12B.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g12B.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g12C.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g12C.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g12D.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2632/data/lamp.g12D.out (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