제출 #1210572

#제출 시각아이디문제언어결과실행 시간메모리
1210572btninhSelotejp (COCI20_selotejp)C++20
0 / 110
0 ms324 KiB
#include <bits/stdc++.h> using namespace std; #define btninh signed main #define int long long #define FOR(i, a, b) for(int i = a; i <= b; ++i) #define fast ios::sync_with_stdio(0); cin.tie(0) #define IO(x) if(fopen(x".inp","r")){freopen(x".inp","r",stdin);freopen(x".out","w",stdout);} template<class Typ> bool mini(Typ &x, Typ y){if (x > y) return x = y, true; return false;} const int N = 1005; const int inf = 1e18; int n, m, dp[2][1 << 11]; char a[N][15]; btninh(){ fast; IO("main"); cin >> n >> m; FOR(i, 1, n) FOR(j, 1, m) cin >> a[i][j]; memset(dp, 0x3f, sizeof dp); dp[0][0] = 0; int cur = 1, lst = 0; FOR(i, 1, n){ FOR(j, 1, m){ FOR(msk, 0, (1 << m) - 1){ int bit = 1 << (j - 1); int val = dp[lst][msk]; if (a[i][j] == '.'){ mini(dp[cur][msk & ~bit], val); // clear đoạn dọc } else { // Dán dọc if (msk & bit){ mini(dp[cur][msk], val); // tiếp tục dán dọc } else { mini(dp[cur][msk | bit], val + 1); // bắt đầu dán dọc mới } // Dán ngang if (j == 1 || a[i][j - 1] == '.' || !(msk & (1 << (j - 2)))){ // bắt đầu dán ngang mới mini(dp[cur][msk], val + 1); } else { // tiếp tục dán ngang mini(dp[cur][msk], val); } } } FOR(msk, 0, (1 << m) - 1) dp[lst][msk] = inf; swap(cur, lst); } } int ans = inf; FOR(msk, 0, (1 << m) - 1) mini(ans, dp[lst][msk]); cout << ans; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:8:45: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define IO(x) if(fopen(x".inp","r")){freopen(x".inp","r",stdin);freopen(x".out","w",stdout);}
      |                                      ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:19:5: note: in expansion of macro 'IO'
   19 |     IO("main");
      |     ^~
Main.cpp:8:72: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define IO(x) if(fopen(x".inp","r")){freopen(x".inp","r",stdin);freopen(x".out","w",stdout);}
      |                                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:19:5: note: in expansion of macro 'IO'
   19 |     IO("main");
      |     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...