이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
            using namespace std;
            int N, R, C;
            int maxL, maxR;
            int A[805][805];
            string S;
            int32_t main() {
                ios_base::sync_with_stdio(0);
                cin.tie(0); cout.tie(0);
                cin >> N >> R >> C >> S; S += S;
                for(int l = 0; l < R; l++)
                    for(int i = 0; i < C; i++)
                        cin >> A[l][i];
                bool west = false, east = false;
                for(int l = 0; l < N; l++)
                    west |= (S[l] == 'W'), east |= (S[l] == 'E');
                if(!west) maxL = 100005;
                if(!east) maxR = 100005;
                for(int l = 0; l < 2 * N; l++) {
                    int i = l;
                    while(i + 1 < 2 * N && (S[i + 1] == S[l])) i++;
                    if(S[l] == 'W') maxL = max(maxL, i - l + 1);
                    if(S[l] == 'E') maxR = max(maxR, i - l + 1);
                    l = i;
                }
                int ans = 1e9 + 7, res = 0;
                for(int l = 0; l < R; l++) {
                    for(int i = 0; i < C; i++) {
                        if(A[l][i] == 0) continue;
                        int x = i, y = i;
                        while(x + 1 < C && A[l][x + 1] != 0 && A[l][x + 1] <= maxL) x++;
                        while(y - 1 >= 0 && A[l][y - 1] != 0 && A[l][y - 1] <= maxR) y--;
                        int cur = x - y + 1;
                        if(cur < ans) ans = cur, res = 0;
                        if(cur == ans) res++;
                    }
                }
                cout << ans << "\n" << res << "\n";
                return 0;
            }
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |