Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("vis.in");
- ofstream fout("vis.out");
- int n, c, nr, a[21][21], posibilitati;
- bool corect(int i, int j)
- {
- return i >= 1 && i <= n && j <= n && j >= 1;
- }
- void vis(int i, int j)
- {
- if(i == n)
- {
- posibilitati++;
- return;
- }
- if(a[i+1][j] == 0 && corect(i+1, j))
- {
- vis(i+1, j);
- }
- if(a[i+1][j-1] == 1 && corect(i+1, j-1))
- {
- vis(i+1, j-1);
- }
- if(a[i+1][j+1] == 1 && corect(i+1, j+1))
- {
- vis(i+1, j+1);
- }
- }
- int main()
- {
- fin >> n >> c >> nr;
- for(int i = 1; i <= nr; i++)
- {
- int x, y;
- fin >> x >> y;
- a[x][y] = 1;
- }
- vis(1, c);
- fout << posibilitati;
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement