# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
736149 | 2023-05-05T09:06:27 Z | marvinthang | Selotejp (COCI20_selotejp) | C++17 | 19 ms | 360 KB |
/****************************** * 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 14 ms | 360 KB | Output is correct |
3 | Correct | 6 ms | 340 KB | Output is correct |
4 | Correct | 8 ms | 332 KB | Output is correct |
5 | Correct | 16 ms | 352 KB | Output is correct |
6 | Correct | 18 ms | 340 KB | Output is correct |
7 | Correct | 15 ms | 340 KB | Output is correct |
8 | Correct | 14 ms | 340 KB | Output is correct |
9 | Correct | 15 ms | 340 KB | Output is correct |
10 | Correct | 17 ms | 356 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 320 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 320 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 14 ms | 360 KB | Output is correct |
3 | Correct | 6 ms | 340 KB | Output is correct |
4 | Correct | 8 ms | 332 KB | Output is correct |
5 | Correct | 16 ms | 352 KB | Output is correct |
6 | Correct | 18 ms | 340 KB | Output is correct |
7 | Correct | 15 ms | 340 KB | Output is correct |
8 | Correct | 14 ms | 340 KB | Output is correct |
9 | Correct | 15 ms | 340 KB | Output is correct |
10 | Correct | 17 ms | 356 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 320 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 320 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 4 ms | 340 KB | Output is correct |
21 | Correct | 9 ms | 336 KB | Output is correct |
22 | Correct | 14 ms | 340 KB | Output is correct |
23 | Correct | 17 ms | 340 KB | Output is correct |
24 | Correct | 15 ms | 340 KB | Output is correct |
25 | Correct | 17 ms | 340 KB | Output is correct |
26 | Correct | 17 ms | 356 KB | Output is correct |
27 | Correct | 18 ms | 352 KB | Output is correct |
28 | Correct | 19 ms | 332 KB | Output is correct |