fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. #define el << "\n"
  5.  
  6. void turbo(){
  7. ios::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9. cout.tie(nullptr);
  10. }
  11.  
  12. void solve(){
  13. int r,c;
  14. for(int i =1;i<=5;++i){
  15. for(int j=1;j<=5;++j){
  16. int x;
  17. cin>>x;
  18. if (x == 1){
  19. r = i;
  20. c = j;
  21. }
  22. }
  23. }
  24. int mr = r - 3,mc = c - 3;
  25. if(mr < 0){
  26. mr = -mr;
  27. }
  28. if(mc < 0){
  29. mc = -mc;
  30. }
  31. cout << mr + mc el;
  32. }
  33.  
  34. int main(){
  35.  
  36. turbo();
  37. solve();
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0.01s 5288KB
stdin
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
stdout
3