Submission #736149

#TimeUsernameProblemLanguageResultExecution timeMemory
736149marvinthangSelotejp (COCI20_selotejp)C++17
110 / 110
19 ms360 KiB
/****************************** * author : @marvinthang * * date : 11 / 02 / 2022 * ******************************/ #include <bits/stdc++.h> using namespace std; #define superspeed ios_base::sync_with_stdio(false); cin.tie(nullptr); // cout.tie(nullptr); #define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); } template <class U, class V> ostream & operator << (ostream& out, const pair<U, V> &p) { return out << '(' << p.first << ", " << p.second << ')'; } template <class T> ostream & operator << (ostream &out, const vector<T> &vt) { out << '{'; for (size_t i = 0; i + 1 < vt.size(); i++) out << vt[i] << ", "; if (!vt.empty()) out << vt.back(); return out << '}'; } const int MOD = 1e9 + 7; const double PI = 3.1415926535897932384626433832795; // acos(-1.0); atan(-1.0); const int dir[] = {0, 1, 0, -1, 0}; // {0, 1, 1, -1, -1, 1, 0, -1, 0}; const long long oo = 1e9; const int MAX = 1003; int N, M; char c[MAX][11]; int main(void) { superspeed; file("coci2021_r3_selotejp"); cin >> N >> M; for (int i = 1; i <= N; ++i) for (int j = 1; j <= M; ++j) cin >> c[i][j]; vector <int> F(1 << M, oo), G(1 << M); F[0] = 0; for (int i = 1; i <= N; ++i) { for (int j = 1; j <= M; ++j) { for (int k = 0; k < 1 << M; ++k) { if (k >> j - 1 & 1) { if (c[i][j] == '.') G[k] = oo; else G[k] = min(F[k], F[k ^ 1 << j - 1] + 1); } else { G[k] = min(F[k], F[k ^ 1 << j - 1]); if (c[i][j] == '#' && (j == 1 || k & 1 << j - 2 || c[i][j - 1] == '.')) ++G[k]; } } F = G; } } cout << *min_element(F.begin(), F.end()); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:37:19: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   37 |        if (k >> j - 1 & 1) {
      |                 ~~^~~
Main.cpp:39:41: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   39 |      else G[k] = min(F[k], F[k ^ 1 << j - 1] + 1);
      |                                       ~~^~~
Main.cpp:41:39: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   41 |         G[k] = min(F[k], F[k ^ 1 << j - 1]);
      |                                     ~~^~~
Main.cpp:43:32: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   43 |          (j == 1 || k & 1 << j - 2 || c[i][j - 1] == '.'))
      |                              ~~^~~
Main.cpp:11:61: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | #define  file(name)  if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
      |                                                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:27:5: note: in expansion of macro 'file'
   27 |     file("coci2021_r3_selotejp");
      |     ^~~~
Main.cpp:11:95: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 | #define  file(name)  if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
      |                                                                                       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:27:5: note: in expansion of macro 'file'
   27 |     file("coci2021_r3_selotejp");
      |     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...