Submission #467278

#TimeUsernameProblemLanguageResultExecution timeMemory
467278maomao90Dango Maker (JOI18_dango_maker)C++17
13 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; template <class T> inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;} template <class T> inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;} #define REP(i, s, e) for (int i = s; i < e; i++) #define RREP(i, s, e) for (int i = s; i >= e; i--) typedef long long ll; typedef long double ld; #define MP make_pair #define FI first #define SE second typedef pair<int, int> ii; typedef pair<ll, ll> pll; #define MT make_tuple typedef tuple<int, int, int> iii; #define ALL(_a) _a.begin(), _a.end() #define pb push_back typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ii> vii; #ifdef DEBUG #define debug(args...) _debug(args) void _debug(const char* format, ...) { va_list args; va_start(args, format); vprintf(format, args); va_end(args); } #else #define debug(args...) #endif #define INF 1000000005 #define LINF 1000000000000000005 #define MOD 1000000007 #define MAXN 3005 int n, m; char s[MAXN][MAXN]; bool used[MAXN][MAXN]; int ans; int main() { scanf("%d%d", &n, &m); REP (i, 0, n) { scanf(" %s", s[i]); } REP (i, 0, n) { REP (j, 0, m) { char a = s[i][j], b, c; bool put = 0; if (j < m - 2) { int cnt = 0; b = s[i][j + 1], c = s[i][j + 2]; if (a == 'R' && b == 'G' && c == 'W') { cnt += used[i][j + 1]; cnt += used[i][j + 2]; if (cnt == 1) { if (used[i][j + 1]) { used[i + 1][j + 1] = 0; } ans--; } if (cnt <= 1) { used[i][j] = 1; used[i][j + 1] = 1; used[i][j + 2] = 1; put = 1; ans++; } } } if (put) continue; if (i < n - 2) { b = s[i + 1][j], c = s[i + 2][j]; if (a == 'R' && b == 'G' && c == 'W') { assert(!used[i][j]); ans++; used[i][j] = used[i + 1][j] = used[i + 2][j] = 1; } } } } printf("%d\n", ans); return 0; } /* 3 4 RGWR GRGG RGWW 4 4 RGWR GRRG WGGW WWWR 5 5 RGRGW GRRGW WGGWR RWRGW RGWGW */

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |   scanf(" %s", s[i]);
      |   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...