Submission #366281

#TimeUsernameProblemLanguageResultExecution timeMemory
366281model_codeSelotejp (COCI20_selotejp)C++17
110 / 110
31 ms512 KiB
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0; i < (n); i++) const int inf = 1e9; int main() { int n, m; scanf("%d%d", &n, &m); char mat[n][m + 1]; REP(i, n) scanf("%s", mat[i]); vector <int> dp(1 << m, inf), novi(1 << m); dp[0] = 0; REP(i, n) { REP(j, m) { REP(k, 1 << m) { if(k & (1 << j)) { if(mat[i][j] == '.') novi[k] = inf; else novi[k] = min(dp[k], dp[k ^ (1 << j)] + 1); } else { novi[k] = min(dp[k], dp[k ^ (1 << j)]); if(mat[i][j] == '#' && (j == 0 || (k & (1 << (j - 1))) || mat[i][j - 1] == '.')) novi[k]++; } } dp = novi; } } printf("%d\n", *min_element(dp.begin(), dp.end())); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:12:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  REP(i, n) scanf("%s", mat[i]);
      |            ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...