Codeforces 1359B - New Theatre Square solution

 Solution in C++:

 ///La ilaha illellahu muhammadur rasulullah

///******Bismillahir-Rahmanir-Rahim******///

///AH Tonmoy

///Department of CSE,23rd batch

    ///Islamic University,Bangladesh

    1. #include <bits/stdc++.h>
    2. using namespace std;
    3. int main()
    4. {
    5. int m,n,x,y,i,j,r,mn,t;
    6. string s;
    7. cin>>t;
    8. while(t--)
    9. {
    10. r=0;
    11. cin>>m>>n>>x>>y;
    12. mn=min(2*x,y);
    13. for(i=0; i<m; i++)
    14. {
    15. cin>>s;
    16. for(j=0; j<n; j++)
    17. {
    18. if(s[j]=='.')
    19. {
    20. if(j+1<n&&s[j+1]=='.')
    21. {
    22. r+=mn;
    23. j++;
    24. }
    25. else
    26. r+=x;
    27. }
    28. }
    29. }
    30. cout<<r<<endl;
    31. }
    32. }

    No comments

    Most View Post

    Recent post

    Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

      Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

    Powered by Blogger.