답안 #366281

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
366281 2021-02-13T19:03:49 Z model_code Selotejp (COCI20_selotejp) C++17
110 / 110
31 ms 512 KB
#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

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]);
      |            ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 17 ms 364 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 8 ms 364 KB Output is correct
5 Correct 19 ms 364 KB Output is correct
6 Correct 19 ms 364 KB Output is correct
7 Correct 19 ms 364 KB Output is correct
8 Correct 17 ms 492 KB Output is correct
9 Correct 31 ms 492 KB Output is correct
10 Correct 20 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 17 ms 364 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 8 ms 364 KB Output is correct
5 Correct 19 ms 364 KB Output is correct
6 Correct 19 ms 364 KB Output is correct
7 Correct 19 ms 364 KB Output is correct
8 Correct 17 ms 492 KB Output is correct
9 Correct 31 ms 492 KB Output is correct
10 Correct 20 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 5 ms 364 KB Output is correct
21 Correct 13 ms 364 KB Output is correct
22 Correct 26 ms 364 KB Output is correct
23 Correct 17 ms 364 KB Output is correct
24 Correct 18 ms 364 KB Output is correct
25 Correct 20 ms 364 KB Output is correct
26 Correct 20 ms 364 KB Output is correct
27 Correct 30 ms 364 KB Output is correct
28 Correct 31 ms 364 KB Output is correct