Submission #79947

#TimeUsernameProblemLanguageResultExecution timeMemory
79947Just_Solve_The_ProblemDango Maker (JOI18_dango_maker)C++11
13 / 100
2 ms720 KiB
#include <bits/stdc++.h> using namespace std; const int N = (int)3e3 + 7; int n, m; char C[N][N]; int c[N][N]; int cost[N]; main() { scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) { getchar(); for (int j = 1; j <= m; j++) { C[i][j] = getchar(); } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (C[i][j] == 'G') { c[i][j] = ((C[i][j - 1] == 'R' && C[i][j + 1] == 'W') || (C[i - 1][j] == 'R' && C[i + 1][j] == 'W')); } } } for (int i = 1; i <= n; i++) { int x, y; x = i; y = 1; int res = 0; while (x >= 1 && y <= m) { if (!c[x][y]) { if (res) { cost[i] += (res + 1) / 2; res = 0; } } else { res++; } x--; y++; } cost[i] += (res + 1) / 2; } int ans = 0; for (int i = 1; i <= n; i++) { ans += cost[i]; } memset(cost, 0, sizeof cost); for (int i = 2; i <= m; i++) { int x, y; x = n; y = i; int res = 0; while (x >= 1 && y <= m) { if (!c[x][y]) { if (res) { cost[i] += (res + 1) / 2; res = 0; } } else { res++; } x--; y++; } cost[i] += (res + 1) / 2; } for (int i = 1; i <= m; i++) { ans += cost[i]; } cout << ans; }

Compilation message (stderr)

dango_maker.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...