Submission #20241

#TimeUsernameProblemLanguageResultExecution timeMemory
20241nova0821빨간 직사각형 (kriii3_QQ)C++98
10 / 20
183 ms81384 KiB
#include <iostream> #define MAX 3002 char input[MAX][MAX]; int countX[MAX][MAX]; int countY[MAX][MAX]; int N, M, result; using namespace std; void count() { for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { if (input[i][j] == 'R') { if (j == 0) countX[i][j] = 1; else countX[i][j] = countX[i][j - 1] + 1; if (i == 0) countY[i][j] = 1; else countY[i][j] = countY[i - 1][j] + 1; } else countX[i][j] = countY[i][j] = 0; } } } void solve() { result = 0; int min; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { min = MAX; for (int k = 0; k < countX[i][j]; k++) { if (min > countY[i][j - k]) min = countY[i][j - k]; result += min; } } } } int main(int argc, char** argv) { ios::sync_with_stdio(false); cin >> N >> M; for (int i = 0; i < N; i++) { cin >> input[i]; } count(); solve(); cout << result << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...