fork download
  1. #include<bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4. #include <ext/pb_ds/assoc_container.hpp>
  5. #include <ext/pb_ds/tree_policy.hpp>
  6. #define fast std::ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
  7. #define clr0(a) memset((a), 0, sizeof(a))
  8. #define clr1(a) memset((a), -1, sizeof(a))
  9. #define srtin1 cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
  10. #define strin2 getline(cin, text);
  11. #define ll long long
  12. #define test cout<<"archit\n"
  13. #define debug(x) cout<<x<<" "
  14. #define debug1(x) cout<<x<<"\n"
  15. #define debug2(x,y) cout<<x<<" "<<y<<"\n"
  16. #define debug3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
  17. #define pb push_back
  18. #define pi pair<int,int>
  19. #define fi first
  20. #define si second
  21. #define mod (ll)1000000007
  22. #define mxn 1000005
  23. #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
  24. using namespace std;
  25. using namespace __gnu_pbds;
  26. bool checkPalindrome(int* arr, int s, int e)
  27. {
  28. if(s > e){
  29. return true;
  30. }
  31. if(arr[s]!=arr[e]){
  32. return false;
  33. }
  34. return checkPalindrome(arr, s+1, e-1);
  35. }
  36. int main()
  37. {
  38. int n,m,k,s;
  39. cin>>n>>m>>k>>s;
  40. vector<string>v(n+1);
  41. for(int i=0;i<=n;i++){
  42. getline(cin, v[i]);
  43. }
  44. int flag=0;
  45. for(int i=1;i<=n;i++){
  46. for(int j=0;j<v[i].length();j+=2){
  47. if(s<=0){
  48. cout<<"No";
  49. exit(0);
  50. }
  51. if(v[i][j] == '.'){
  52. s-=2;
  53. }
  54. else if(v[i][j] == '*'){
  55. s+=5;
  56. }
  57. else if(v[i][j] == '#'){
  58. flag=1;
  59. break;
  60. }
  61. if(j!=(v[i].length()-1))
  62. s-=1;
  63. if(s<=0){
  64. cout<<"No";
  65. exit(0);
  66. }
  67. //debug(s);
  68. }
  69. if(flag){
  70. break;
  71. }
  72. }
  73. (s >= k) ? cout<<"Yes\n"<<s : cout<<"No";
  74. return 0;
  75. }
Success #stdin #stdout 3.14s 15240KB
stdin
Standard input is empty
stdout
No