fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. #define INF 1LL<<62
  5. #define inf 1000000007
  6.  
  7. string s[22];
  8. int main() {
  9. ll n,l;
  10. cin>>n>>l;
  11. cin.ignore();
  12. for(ll i=0;i<=l;i++){
  13. getline(cin,s[i]);
  14. }
  15. ll ans=0;
  16. for(ll i=0;i<2*n-1;i++){
  17. if(s[l][i]=='o'){
  18. ans=i;
  19. }
  20. }
  21. //cout <<ans;
  22. for(ll i=l-1;i>=0;i--){
  23. for(ll j=0;j<2*n-1;j++){
  24. if(s[i][j]=='-'){
  25. if(j==ans-1){
  26. ans-=2;
  27. }
  28. else if(j==ans+1){
  29. ans+=2;
  30. }
  31. }
  32. }
  33. }
  34. cout << 1+ans/2<<endl;
  35. // your code goes here
  36. return 0;
  37. }
Success #stdin #stdout 0s 4288KB
stdin
3 2
| |-|
|-| |
o    
stdout
3