Submission #862175

#TimeUsernameProblemLanguageResultExecution timeMemory
862175green_gold_dogDango Maker (JOI18_dango_maker)C++17
100 / 100
307 ms47184 KiB
//#pragma GCC optimize("Ofast") //#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,popcnt,mmx") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double db; typedef long double ldb; typedef complex<double> cd; constexpr ll INF64 = 9'000'000'000'000'000'000, INF32 = 2'000'000'000, MOD = 1'000'000'007; constexpr db PI = acos(-1); constexpr bool IS_FILE = false, IS_TEST_CASES = false; random_device rd; mt19937 rnd32(rd()); mt19937_64 rnd64(rd()); template<typename T> bool assign_max(T& a, T b) { if (b > a) { a = b; return true; } return false; } template<typename T> bool assign_min(T& a, T b) { if (b < a) { a = b; return true; } return false; } template<typename T> T square(T a) { return a * a; } template<> struct std::hash<pair<ll, ll>> { ll operator() (pair<ll, ll> p) const { return ((__int128)p.first * MOD + p.second) % INF64; } }; bool check1(ll x, ll y, vector<vector<bool>>& used, vector<vector<char>>& arr) { ll n = used.size(), m = used[0].size(); if (y < 0 || x < 0 || y >= m || x + 2 >= n) { return false; } return !used[x][y] && !used[x + 1][y] && !used[x + 2][y] && arr[x][y] == 'R' && arr[x + 1][y] == 'G' && arr[x + 2][y] == 'W'; } bool check2(ll x, ll y, vector<vector<bool>>& used, vector<vector<char>>& arr) { ll n = used.size(), m = used[0].size(); if (y < 0 || x < 0 || y + 2 >= m || x >= n) { return false; } return !used[x][y] && !used[x][y + 1] && !used[x][y + 2] && arr[x][y] == 'R' && arr[x][y + 1] == 'G' && arr[x][y + 2] == 'W'; } void solve() { ll n, m; cin >> n >> m; vector<vector<char>> arr(n, vector<char>(m)); ll ans = 0; vector<vector<bool>> used(n, vector<bool>(m, false)); vector<vector<ll>> r(n); for (ll i = 0; i < n; i++) { for (ll j = 0; j < m; j++) { cin >> arr[i][j]; if (arr[i][j] == 'R') { r[i].push_back(j); } } } for (ll i = 0; i < n; i++) { for (ll j = 0; j < m; j++) { if (check2(i, j, used, arr)) { ans++; used[i][j] = true; used[i][j + 1] = true; used[i][j + 1] = true; continue; } bool b = false; ll c = 0; while (true) { if (!check1(i + c, j - c, used, arr)) { b = true; break; } c++; if (!check2(i + c, j - c, used, arr)) { break; } } if (b) { for (ll k = 1; k <= c; k++) { if (check2(i + k, j - k, used, arr)) { ans++; used[i + k][j - k] = true; used[i + k][j - k + 1] = true; used[i + k][j - k + 2] = true; } } } else { for (ll k = 0; k <= c; k++) { if (check1(i + k, j - k, used, arr)) { ans++; used[i + k][j - k] = true; used[i + k + 1][j - k] = true; used[i + k + 2][j - k] = true; } } } } } cout << ans << '\n'; } int main() { if (IS_FILE) { freopen("", "r", stdin); freopen("", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t = 1; if (IS_TEST_CASES) { cin >> t; } for (ll i = 0; i < t; i++) { solve(); } }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:128:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  128 |                 freopen("", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:129:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  129 |                 freopen("", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...