Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma warning(disable: 4996)
- #pragma comment(linker,"/STACK:64000000")
- #include <iostream>
- #include <sstream>
- #include <stdio.h>
- #include <memory.h>
- #include <algorithm>
- #include <map>
- #include <string>
- #include <cstring>
- #include <vector>
- #include <cmath>
- #include <queue>
- #include <deque>
- #include <stack>
- #include <cassert>
- #include <time.h>
- #include <bitset>
- using namespace std;
- #define mp make_pair
- #define pb push_back
- #define _(a,b) memset( (a), b, sizeof( a ) )
- #define all(a) a.begin(), a.end()
- #define sz(a) (int)a.size()
- #define foreach(struct, iterator) for (iterator=struct.begin(); iterator != struct.end(); ++iterator)
- #define forn(i, n) for (i=0; i < n; i++)
- #define forab(i, a, b) for (i=a; i < b; i++)
- typedef unsigned long long ull;
- typedef long long lint;
- typedef pair < int , int > pii;
- typedef long double ld;
- const int INF = 1000 * 1000 * 1000;
- const lint LINF = 1000000000000000000LL;
- const double eps = 1e-9;
- void prepare(string s)
- {
- #ifndef _DEBUG
- freopen("input.txt", "r", stdin);
- #else
- if (sz(s) != 0)
- {
- freopen((s + ".in").c_str(),"r",stdin);
- freopen((s + ".out").c_str(),"w",stdout);
- }
- #endif
- }
- char lab[10][16];
- pii st, d[3]={mp(1, 0), mp(0, 1), mp(0, -1)};
- bool used[10][16];
- int L[10][16];
- vector <int> ans;
- bool inlab(pii pos)
- {
- return (pos.first >= 0) && (pos.first < 10) && (pos.second >= 0) && (pos.second < 16);
- }
- void dfs(pii pos)
- {
- int i;
- pii nd;
- used[pos.first][pos.second]=true;
- L[pos.first][pos.second]=1;
- if (pos.first < 9)
- {
- for (i=0; i<3; i++)
- {
- nd=mp(pos.first+d[i].first, pos.second+d[i].second);
- if (inlab(nd) && (!used[nd.first][nd.second]) && (lab[nd.first][nd.second] == '0'))
- {
- if (i == 0) i=3;
- dfs(nd);
- }
- }
- }
- }
- int main()
- {
- int i, j;
- prepare("lines");
- forn(i, 10)
- {
- forn(j, 16)
- {
- lab[i][j]=getchar();
- if (lab[i][j] == 'x') st=mp(i, j);
- if (lab[i][j] == '1')
- {
- used[i][j]=true;
- L[i][j]=-1;
- }
- }
- getchar();
- }
- dfs(st);
- forn(i, 16)
- if (L[9][i] == 1) ans.pb(i+1);
- if (sz(ans) == 0) cout << "IMPOSSIBLE";
- else
- {
- forn(i, sz(ans)-1) cout << ans[i] << " ";
- cout << ans.back();
- }
- return 0;
- }
- //000000*x********
- //111111*11111111*
- //****************
- //*11111111*111111
- //************0000
- //1111*111111*1110
- //0*****1100******
- //1*11111001*11111
- //****01001****000
- //111*11011*11*110
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement