Guest User

Untitled

a guest
Mar 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main () {
  4. int output[2];
  5. for (int a = 0; a < 2; a++) {
  6.  
  7. int m, ci, cj, N;
  8. cin >> m;
  9. char city[m][m+1];
  10. for (int i = 0; i < m; i++) {
  11. cin >> city[i];
  12. }
  13. cin >> ci >> cj >> N;
  14.  
  15. int ways = 0;
  16. int now[9999999];
  17. int save[9999999];
  18. int citys = 1;
  19. for (int i = 0; i < 9999999; i++) {
  20. now[i] = 0;
  21. save[i] = 0;
  22. }
  23. now[0] = ci - 1;
  24. for (int i = 0; i < N; i++) {
  25. int nownum = 0;
  26. //cout << "距離" << i << endl;
  27. for (int k = 0; k < citys; k++) {
  28. //cout << "citys" << citys << endl;
  29. for (int j = 0; j < m; j++) {
  30. //cout << "j" << j << endl;
  31. if (city[now[k]][j] == '1') {
  32. //cout << "if" << endl;
  33. save[nownum] = j;
  34. nownum++;
  35. if (j == cj-1)
  36. ways++;
  37. }
  38. }
  39. }
  40. for (int i = 0; i < 9999999; i++) {
  41. now[i] = save[i];
  42. }
  43. citys = nownum;
  44. }
  45.  
  46. output[a] = ways;
  47. }
  48.  
  49. for (int i = 0; i < 2; i++) {
  50. cout << output[i];
  51. }
  52.  
  53. return 0;
  54. }
Add Comment
Please, Sign In to add comment