Submission #1050196

#TimeUsernameProblemLanguageResultExecution timeMemory
1050196vjudge1Dango Maker (JOI18_dango_maker)C++17
33 / 100
419 ms38448 KiB
#include <bits/stdc++.h> #ifdef ONLINE_JUDGE #undef ONLINE_JUDGE #else #define ONLINE_JUDGE #endif #ifndef ONLINE_JUDGE #include "debug.cpp" #else #define debug(...) #define debugArr(...) #endif #pragma region #define int long long #define vec vector #define vlong vec<long> #define vint vec<int> #define vchar vec<char> #define vbool vec<bool> #define vvint vec<vint> #define vstr vec<string> #define vstring vstr #define vpint vec<pair<int, int> > #define CININT(n) INTCIN(n); #define INTCIN(n) int n; cin >> n; #define INTCINVINTCIN(a, n) INTCIN(n); vint a(n); CINV(a, n); #define TWOVECS(a, b, n) INTCIN(n); vint a(n), b(n); CINV(a, n) CINV (b, n); #define TWOCOLS(a, b, n) INTCIN(n); vint a(n), b(n); CINVV(a, b, n); #define ICVK(n, k, a) CININT(n); CININT(k); vint a(n); CINV(a, n); #define ICVK1(n, k, a) ICVK(n, k, a) #define ICVK2(n, k, h, a) CININT(n); CININT(k); CININT(h); vint a(n); CINV(a, n); #define ICVK3(n, k, h, m, a) CININT(n); CININT(k); CININT(h); CININT(m); vint a(n); CINV(a, n); #define CIN(n) cin >> n; #define COUT(n) cout << n; #define CINV(a, n) for (int i = 0; i < n; i++) {cin >> a[i];} #define CINVV(a, b, n) for (int i = 0; i < n; i++) {cin >> a[i] >> b[i];} #define COUTV(a, n) for (int i = 0; i < n; i++) {cout << a[i] << " ";} #define COUTVV(a, b, n) for (int i = 0; i < n; i++) {cout << a[i] << " " << b[i] << "\n";} #define NOSPACE(a, n) for (int i = 0;i < n;i++) {cout << a[i];} #define ENDL cout << "\n"; #define SORT(a) sort(a.begin(), a.end()); #define REVERSE(a) reverse(a.begin(), a.end()); #define HAS(theset, num) ((theset.find((num)) != (theset.end()))) #define FOR(i, n) for (int i = 0; i < n; i++) #define FOR1(i, n) for (int i = 1; i < n; i++) #define YES if (true) {cout << "YES"; return;} #define NO if (true) {cout << "NO"; return;} #define Yes if (true) {cout << "Yes"; return;} #define No if (true) {cout << "No"; return;} #define IMPOS if (true) {cout << "Impossible"; return;} #define IMPOSS IMPOS #define SP " " #define NEWLINE "\n" #define Q int q;cin>>q;while(q--) #pragma endregion using namespace std; vec<vbool> ignore_me_left; vec<vbool> ignore_me_up; bool amleft(int x, int y, vec<vec<short> > & grid) { if (x < 2) return false; return !ignore_me_left[y][x] and (grid[y][x] == 3 && grid[y][x-1] == 2 && grid[y][x-2] == 1); } bool amup(int x, int y, vec<vec<short> > & grid) { if (y < 2) return false; return !ignore_me_up[y][x] and (grid[y][x] == 3 && grid[y-1][x] == 2 && grid[y-2][x] == 1); } int conflictsmeleft(int x, int y, vec<vec<short> > & grid) { return amup(x-1, y+1, grid) + amup(x-2, y+2, grid); } int conflictsmeup(int x, int y, vec<vec<short> > & grid) { return amleft(x+1, y-1, grid) + amleft(x+2, y-2, grid); } void pre() {} // you can do this! const bool DO_ENDL = true; const bool MULTI_T = false; // :skull: dont forgorr me!! void solve() { int n, m; cin >> n >> m; ignore_me_left = vec<vbool>(n+2, vbool(m+2, 0)); ignore_me_up = vec<vbool>(n+2, vbool(m+2, 0)); vec<vec<short> > grid(n+2, vec<short>(m+2, 0)); vec<vec<short> > conflicts(n+2, vec<short>(m+2, 0)); // vec<vbool> left(n+2, vbool(m+2, 0)); // vec<vbool> up(n+2, vbool(m+2, 0)); for (int y = 0; y < n; y++) { string s; cin >> s; for (int x = 0; x < m; x++) { char c = s[x]; if (c == 'R') { grid[y][x] = 1; } if (c == 'G') { grid[y][x] = 2; } if (c == 'W') { grid[y][x] = 3; } } } debug(grid); int counter = 0; // conflictless for (int x = 0; x < m; x++) { for (int y = 0; y < n; y++) { if (amleft(x, y, grid)) { int conflicts = conflictsmeleft(x, y, grid); if (conflicts == 0) { counter++; // debug(x, y); grid[y][x] = 0; } } if (amup(x, y, grid)) { int conflicts = conflictsmeup(x, y, grid); if (conflicts == 0) { counter++; // debug(x, y); grid[y][x] = 0; } // debug(conflicts, x, y); } } } for (int x = m-1; x != -1; x--) { for (int y = n-1; y != -1; y--) { if (amleft(x, y, grid)) { int conflicts = conflictsmeleft(x, y, grid); if (conflicts == 0) { counter++; // debug(x, y); grid[y][x] = 0; } } if (amup(x, y, grid)) { int conflicts = conflictsmeup(x, y, grid); if (conflicts == 0) { counter++; // debug(x, y); grid[y][x] = 0; } } } } // above must be done iteratively multiple times from different dirs I tihnk // 1 conflict for (int x = m-1; x != -1; x--) { for (int y = n-1; y != -1; y--) { if (amup(x, y, grid)) { int conflicts = conflictsmeup(x, y, grid); if (conflicts == 0) { counter++; debug(x, y); grid[y][x] = 0; grid[y-1][x] = 0; grid[y-2][x] = 0; } } if (amleft(x, y, grid)) { int conflicts = conflictsmeleft(x, y, grid); if (conflicts <= 1) { counter++; debug(x, y); grid[y][x] = 0; grid[y][x-1] = 0; grid[y][x-2] = 0; } } if (amup(x, y, grid)) { int conflicts = conflictsmeup(x, y, grid); if (conflicts <= 1) { counter++; debug(x, y); grid[y][x] = 0; grid[y-1][x] = 0; grid[y-2][x] = 0; } } } } for (int x = 0; x < m; x++) { for (int y = 0; y < n; y++) { if (amup(x, y, grid)) { int conflicts = conflictsmeup(x, y, grid); if (conflicts == 0) { counter++; debug(x, y); grid[y][x] = 0; grid[y-1][x] = 0; grid[y-2][x] = 0; } } if (amleft(x, y, grid)) { int conflicts = conflictsmeleft(x, y, grid); if (conflicts <= 1) { counter++; debug(x, y); grid[y][x] = 0; grid[y][x-1] = 0; grid[y][x-2] = 0; } } if (amup(x, y, grid)) { int conflicts = conflictsmeup(x, y, grid); if (conflicts <= 1) { counter++; debug(x, y); grid[y][x] = 0; grid[y-1][x] = 0; grid[y-2][x] = 0; } } } } cout << counter; } signed main() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); pre(); if (not MULTI_T) {solve(); return 0;} CININT(t); while (t--) { solve(); if (DO_ENDL) ENDL; } }

Compilation message (stderr)

dango_maker.cpp:16: warning: ignoring '#pragma region ' [-Wunknown-pragmas]
   16 | #pragma region
      | 
dango_maker.cpp:69: warning: ignoring '#pragma endregion ' [-Wunknown-pragmas]
   69 | #pragma endregion
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...