제출 #564190

#제출 시각아이디문제언어결과실행 시간메모리
5641904fecta바이러스 (JOI19_virus)C++17
14 / 100
628 ms10316 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define int ll #define ld long double #define pii pair<int, int> #define f first #define s second #define boost() cin.tie(0), cin.sync_with_stdio(0) const int MN = 805; int len, n, m, a[MN][MN]; string s; int32_t main() { boost(); cin >> len >> n >> m >> s; while (s.length() < 1e6) s += s; int me = 0, mw = 0, l = 0; for (char c : s) { if (c == 'E') l++; else me = max(me, l), l = 0; } me = max(me, l); l = 0; for (char c : s) { if (c == 'W') l++; else mw = max(mw, l), l = 0; } mw = max(mw, l); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; if (!a[i][j]) a[i][j] = 0x3f3f3f3f; } } int mn = 0x3f3f3f3f, cnt = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (a[i][j] == 0x3f3f3f3f) continue; int l = j, r = j; while (1) { if (l > 1 && a[i][l - 1] <= me) { l--; continue; } if (r < m && a[i][r + 1] <= mw) { r++; continue; } break; } if (r - l + 1 < mn) mn = r - l + 1, cnt = 1; else if (r - l + 1 == mn) cnt++; } } printf("%lld\n%lld\n", mn, cnt); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...