fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. template<class S, class T> inline S min_L(S a,T b){
  5. return a<=b?a:b;
  6. }
  7. template<class S, class T> inline S chmin(S &a, T b){
  8. if(a>b){
  9. a=b;
  10. }
  11. return a;
  12. }
  13. #define main dummy_main
  14. int main(){
  15. return 0;
  16. }
  17. #undef main
  18. int X;
  19. int Y;
  20. int dp[200][200];
  21. class Solution{
  22. public:
  23. int minFallingPathSum(vector<vector<int>>& A){
  24. int i, j;
  25. int mn1;
  26. int mn1p;
  27. int mn2;
  28. X = A.size();
  29. Y = A[0].size();
  30. for(j=(0);j<(Y);j++){
  31. dp[0][j] = A[0][j];
  32. }
  33. for(i=(1);i<(X);i++){
  34. mn1 = mn2 = 1073709056;
  35. for(j=(0);j<(Y);j++){
  36. if(mn1 > dp[i-1][j]){
  37. mn1 = dp[i-1][j];
  38. mn1p = j;
  39. }
  40. }
  41. for(j=(0);j<(Y);j++){
  42. if(j != mn1p){
  43. chmin(mn2, dp[i-1][j]);
  44. }
  45. }
  46. for(j=(0);j<(Y);j++){
  47. if(j!=mn1p){
  48. dp[i][j] =mn1+ A[i][j];
  49. }
  50. else{
  51. dp[i][j] =mn2+ A[i][j];
  52. }
  53. }
  54. }
  55. {
  56. int KrdatlYV;
  57. int ao_dF3pO;
  58. if(Y==0){
  59. ao_dF3pO = 0;
  60. }
  61. else{
  62. ao_dF3pO = dp[X-1][0];
  63. for(KrdatlYV=(1);KrdatlYV<(Y);KrdatlYV++){
  64. ao_dF3pO = min_L(ao_dF3pO, dp[X-1][KrdatlYV]);
  65. }
  66. }
  67. return ao_dF3pO;
  68. }
  69. }
  70. }
  71. ;
  72. // cLay varsion 20191214-1
  73.  
  74. // --- original code ---
  75. // #define main dummy_main
  76. // {}
  77. // #undef main
  78. //
  79. // int X, Y;
  80. // int dp[200][200];
  81. //
  82. //
  83. // class Solution {
  84. // public:
  85. // int minFallingPathSum(vector<vector<int>>& A) {
  86. // int mn1, mn1p, mn2;
  87. // X = A.size();
  88. // Y = A[0].size();
  89. //
  90. // rep(j,Y) dp[0][j] = A[0][j];
  91. // rep(i,1,X){
  92. // mn1 = mn2 = int_inf;
  93. // rep(j,Y) if(mn1 > dp[i-1][j]) mn1 = dp[i-1][j], mn1p = j;
  94. // rep(j,Y) if(j != mn1p) mn2 <?= dp[i-1][j];
  95. // rep(j,Y) dp[i][j] = if[j!=mn1p, mn1, mn2] + A[i][j];
  96. // }
  97. //
  98. // return min(dp[X-1](Y));
  99. // }
  100. // };
  101.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty