Submission #991141

#TimeUsernameProblemLanguageResultExecution timeMemory
991141gmroh06JOI 문장 (JOI14_ho_t1)C++17
100 / 100
26 ms42092 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<ll, ll>; inline void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } ll n, m, dp[1010][1010][5], ans, h[4][4], p; char s[1010][1010], joi[3][3]; ll dx[] = {0, 0, -1, -1}, dy[] = {0, -1, 0, -1}; int main() { fastio(); cin >> m >> n; for (ll i = 0; i < m; i++) { cin >> s[i]; } cin >> joi[0] >> joi[1]; for (ll i = 0; i < 2; i++) { for (ll j = 0; j < 2; j++) { h[i][j] = 2 * (joi[i][j] == 'I') + (joi[i][j] == 'O'); } } for (ll i = 1; i < m; i++) { for (ll j = 1; j < n; j++) { ll cnt = 0, x, y; for (ll k = 0; k < 4; k++) { ll nx = i + dx[k], ny = j + dy[k]; if (joi[1 + dx[k]][1 + dy[k]] == s[nx][ny]) { cnt++; } else { x = nx, y = ny; } } if (cnt == 4) { ans++; for (ll k = 0; k < 4; k++) { ll nx = i + dx[k], ny = j + dy[k]; for (ll l = 0; l < 3; l++) { if (l != h[1 + dx[k]][1 + dy[k]]) { dp[nx][ny][l]--; } } } } else if (cnt == 3) { dp[x][y][h[x - i + 1][y - j + 1]]++; } } } for (ll i = 0; i < m; i++) { for (ll j = 0; j < n; j++) { for (ll k = 0; k < 3; k++) { p = max(p, dp[i][j][k]); } } } cout << ans + p; return 0; }

Compilation message (stderr)

2014_ho_t1.cpp: In function 'int main()':
2014_ho_t1.cpp:61:50: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   61 |                 dp[x][y][h[x - i + 1][y - j + 1]]++;
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
2014_ho_t1.cpp:61:50: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...