Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- $$$$$$$\ $$\ $$$$$$$\
- $$ __$$\ \__| $$ __$$\
- $$ | $$ | $$$$$$\ $$$$$$\ $$\ $$$$$$$\ $$ | $$ | $$$$$$\ $$$$$$\ $$$$$$$\ $$$$$$\
- $$$$$$$\ |$$ __$$\ $$ __$$\ $$ |$$ _____|$$$$$$$\ | \____$$\ $$ __$$\ $$ _____|\____$$\
- $$ __$$\ $$ / $$ |$$ | \__|$$ |\$$$$$$\ $$ __$$\ $$$$$$$ |$$ | \__|$$ / $$$$$$$ |
- $$ | $$ |$$ | $$ |$$ | $$ | \____$$\ $$ | $$ |$$ __$$ |$$ | $$ | $$ __$$ |
- $$$$$$$ |\$$$$$$ |$$ | $$ |$$$$$$$ |$$$$$$$ |\$$$$$$$ |$$ | \$$$$$$$\\$$$$$$$ |
- \_______/ \______/ \__| \__|\_______/ \_______/ \_______|\__| \_______|\_______|
- */
- #include <bits/stdc++.h>
- typedef long long ll;
- #define pb push_back
- #define mp make_pair
- #define pii pair <int,int>
- #define in insert
- #define X first
- #define Y second
- #define frn front
- #define bc back
- #define rep(i,a,b)for (ll (i) = (a); (i) < b(); ++(i))
- #define _ << " " <<
- #define sz(x) (int)x.size()
- #define all(a) (a).begin(),(a).end()
- using namespace std;
- const int MAXN = 100;
- int a, b, c, x, y, sol = 10000;
- map <pii, int> m;
- vector <int> graph[MAXN];
- void bfs(){
- bool bio[100];
- memset(bio, 0, sizeof bio);
- queue <int> q;
- q.push(x);
- q.push(0);
- while (!q.empty()){
- x = q.frn();
- q.pop();
- int t = q.frn();
- q.pop();
- cout <<x _ t<<endl;
- if (x == y){
- sol = min(sol, t);
- continue;
- }
- if (bio[x])
- continue;
- bio[x]++;
- for (auto u : graph[x]){
- q.push(u);
- q.push(t + m[mp(x, u)]);
- }
- }
- }
- int main () {
- ios_base::sync_with_stdio(false);
- cin >>a>>b>>c;
- graph[1] = {8, 7, 2};
- graph[2] = {1, 3, 9};
- graph[3] = {2, 10, 4};
- graph[4] = {3, 5, 11};
- graph[5] = {6, 4, 12};
- graph[6] = {7, 13, 5};
- graph[7] = {6, 1, 14};
- graph[8] = {14, 9, 1};
- graph[9] = {8, 10, 2};
- graph[10] = {9, 11, 3};
- graph[11] = {10, 12, 4};
- graph[12] = {11, 13, 5};
- graph[13] = {12, 14, 6};
- graph[14] = {13, 8, 7};
- for (int i = 1; i < 8; ++i)
- for (int j = 1; j < 8; ++j)
- m[mp(i, j)] = a;
- for (int i = 8; i < 15; ++i)
- for (int j = 8; j < 15; ++j)
- m[mp(i, j)] = b;
- for (int i = 1; i < 8; ++i)
- m[mp(i, i + 7)] = c;
- for (int i = 8; i < 15; ++i)
- m[mp(i, i - 7)] = c;
- cin >>x>>y;
- bfs();
- cout <<sol<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement