답안 #236072

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
236072 2020-05-31T06:59:21 Z NONAME Retro (COCI17_retro) C++17
0 / 100
136 ms 109304 KB
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define N 100500
#define oo ll(1e16)
#define ft first
#define sd second
#define pb push_back
#define ppb pop_back
#define el '\n'
#define elf endl
#define base ll(1e9 + 7)
using namespace std;

typedef long long ll;
typedef long double ld;

int n, m, f[300][300][300];
string s[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> m;
    for (int i = 0; i < n; i++)
		cin >> s[i];

	for (int i = 0; i < n - i - 1; i++)
		swap(s[i], s[n - i - 1]);

	for (int i = 0; i < n; i++)
	for (int j = 0; j < m; j++)
	for (int k = 0; k < n; k++)
		f[i][j][0] = -1;
    for (int i = 0; i < n - 1; i++)
	for (int j = 0; j < m; j++)
        if (i == 0) {
			if (s[i][j] == 'M') {
                if (j - 1 >= 0 && s[i + 1][j - 1] != '*') {
					if (s[i + 1][j - 1] == '.') {
						for (int k = 0; k < n; k++)
                            f[i + 1][j - 1][k] = max(f[i + 1][j - 1][k], f[i][j][k]);
					} else {
						if (s[i + 1][j - 1] == '(') {
							for (int k = 0; k < n; k++)
								if (f[i][j][k] != -1)
									f[i + 1][j - 1][k + 1] = max(f[i + 1][j - 1][k + 1], f[i][j][k] + 1);
						} else {
                            for (int k = 1; k < n; k++)
								if (f[i][j][k] != -1)
									f[i + 1][j - 1][k - 1] = max(f[i + 1][j - 1][k - 1], f[i][j][k] + 1);
						}
					}
                }
                if (s[i + 1][j] != '*') {
					if (s[i + 1][j] == '.') {
						for (int k = 0; k < n; k++)
                            f[i + 1][j][k] = max(f[i + 1][j][k], f[i][j][k]);
					} else {
						if (s[i + 1][j] == '(') {
							for (int k = 0; k < n; k++)
								if (f[i][j][k] != -1)
									f[i + 1][j][k + 1] = max(f[i + 1][j][k + 1], f[i][j][k] + 1);
						} else {
                            for (int k = 1; k < n; k++)
								if (f[i][j][k] != -1)
									f[i + 1][j][k - 1] = max(f[i + 1][j][k - 1], f[i][j][k] + 1);
						}
					}
                }
                if (j + 1 < m && s[i + 1][j + 1] != '*') {
					if (s[i + 1][j + 1] == '.') {
						for (int k = 0; k < n; k++)
                            f[i + 1][j + 1][k] = max(f[i + 1][j + 1][k], f[i][j][k]);
					} else {
						if (s[i + 1][j + 1] == '(') {
							for (int k = 0; k < n; k++)
								if (f[i][j][k] != -1)
									f[i + 1][j + 1][k + 1] = max(f[i + 1][j + 1][k + 1], f[i][j][k] + 1);
						} else {
                            for (int k = 1; k < n; k++)
								if (f[i][j][k] != -1)
									f[i + 1][j + 1][k - 1] = max(f[i + 1][j + 1][k - 1], f[i][j][k] + 1);
						}
					}
                }
			}
        } else {
			if (j - 1 >= 0 && s[i + 1][j - 1] != '*') {
				if (s[i + 1][j - 1] == '.') {
					for (int k = 0; k < n; k++)
						f[i + 1][j - 1][k] = max(f[i + 1][j - 1][k], f[i][j][k]);
				} else {
					if (s[i + 1][j - 1] == '(') {
						for (int k = 0; k < n; k++)
							if (f[i][j][k] != -1)
								f[i + 1][j - 1][k + 1] = max(f[i + 1][j - 1][k + 1], f[i][j][k] + 1);
					} else {
						for (int k = 1; k < n; k++)
							if (f[i][j][k] != -1)
								f[i + 1][j - 1][k - 1] = max(f[i + 1][j - 1][k - 1], f[i][j][k] + 1);
					}
				}
			}
			if (s[i + 1][j] != '*') {
				if (s[i + 1][j] == '.') {
					for (int k = 0; k < n; k++)
						f[i + 1][j][k] = max(f[i + 1][j][k], f[i][j][k]);
				} else {
					if (s[i + 1][j] == '(') {
						for (int k = 0; k < n; k++)
							if (f[i][j][k] != -1)
								f[i + 1][j][k + 1] = max(f[i + 1][j][k + 1], f[i][j][k] + 1);
					} else {
						for (int k = 1; k < n; k++)
							if (f[i][j][k] != -1)
								f[i + 1][j][k - 1] = max(f[i + 1][j][k - 1], f[i][j][k] + 1);
					}
				}
			}
			if (j + 1 < m && s[i + 1][j + 1] != '*') {
				if (s[i + 1][j + 1] == '.') {
					for (int k = 0; k < n; k++)
						f[i + 1][j + 1][k] = max(f[i + 1][j + 1][k], f[i][j][k]);
				} else {
					if (s[i + 1][j + 1] == '(') {
						for (int k = 0; k < n; k++)
							if (f[i][j][k] != -1)
								f[i + 1][j + 1][k + 1] = max(f[i + 1][j + 1][k + 1], f[i][j][k] + 1);
					} else {
						for (int k = 1; k < n; k++)
							if (f[i][j][k] != -1)
								f[i + 1][j + 1][k - 1] = max(f[i + 1][j + 1][k - 1], f[i][j][k] + 1);
					}
				}
			}
		}

    int mx = 0;
    for (int i = 0; i < n; i++)
	for (int j = 0; j < m; j++)
		mx = max(mx, f[i][j][0]);

	cout << mx;
}

Compilation message

retro.cpp: In function 'int main()':
retro.cpp:142:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (int i = 0; i < n; i++)
     ^~~
retro.cpp:146:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  cout << mx;
  ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 3584 KB Unexpected end of file - token expected
2 Incorrect 6 ms 3840 KB Unexpected end of file - token expected
3 Incorrect 7 ms 3712 KB Unexpected end of file - token expected
4 Incorrect 7 ms 4096 KB Unexpected end of file - token expected
5 Incorrect 7 ms 5248 KB Unexpected end of file - token expected
6 Incorrect 11 ms 9216 KB Unexpected end of file - token expected
7 Incorrect 13 ms 12160 KB Unexpected end of file - token expected
8 Incorrect 10 ms 7680 KB Unexpected end of file - token expected
9 Incorrect 13 ms 12288 KB Unexpected end of file - token expected
10 Incorrect 16 ms 15616 KB Unexpected end of file - token expected
11 Incorrect 124 ms 102648 KB Unexpected end of file - token expected
12 Incorrect 112 ms 102648 KB Unexpected end of file - token expected
13 Incorrect 59 ms 47608 KB Unexpected end of file - token expected
14 Incorrect 54 ms 47480 KB Unexpected end of file - token expected
15 Incorrect 130 ms 108920 KB Unexpected end of file - token expected
16 Incorrect 128 ms 108920 KB Unexpected end of file - token expected
17 Incorrect 115 ms 92932 KB Unexpected end of file - token expected
18 Incorrect 108 ms 92920 KB Unexpected end of file - token expected
19 Incorrect 136 ms 109304 KB Unexpected end of file - token expected
20 Incorrect 133 ms 109304 KB Unexpected end of file - token expected