Submission #824020

#TimeUsernameProblemLanguageResultExecution timeMemory
824020AmirElarbiDango Maker (JOI18_dango_maker)C++14
13 / 100
1 ms340 KiB
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #define INF 1e9 #define ve vector #define vi ve<int> #define ii pair<int,int> #define vii ve<ii> #define pb push_back #define fi first #define se second #define ll long long using namespace __gnu_pbds; using namespace std; const int nax = 3e3+5; const int kax = 25+5; const int MOD = 1e9+7; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; map<char,int> mp; char grid[nax][nax]; int inv[3] = {'R', 'G', 'W'}; int n,m, ans[nax][nax][2]; queue<pair<ii,int>> res[4]; bool check(int x, int y, bool type){ for (int i = 0; i < 3; ++i) { if(x >= n || y >= m || x < 0 || y < 0) return false; if(grid[x][y] != inv[i]) return false; x += !type, y += type; } return true; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); mp['R'] = 0, mp['G'] = 1, mp['W'] = 2; cin >> n >> m; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> grid[i][j]; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if(grid[i][j] == 'R'){ if(check(i,j,1)){ int cnt = 0; for (int k = 0;k < 3; ++k) { if(check(i-k,j+k,0)) cnt++; } res[cnt].push({{i,j},1}); ans[i][j][1] = cnt; } if(check(i,j,0)){ int cnt = 0; for (int k = 0;k < 3; ++k) { if(check(i+k,j-k,1)) cnt++; } res[cnt].push({{i,j},0}); ans[i][j][0] = cnt; } } } } for (int cnt = 3; cnt > 0; --cnt) { while(!res[cnt].empty()){ pair<ii,int> st = res[cnt].front(); int i = st.fi.fi, j = st.fi.se; res[cnt].pop(); if(ans[i][j][st.se] != cnt){ res[ans[i][j][st.se]].push({st}); continue; } for (int k = 0;k < 3; ++k) { if(st.se && check(i-k,j+k,0)) ans[i-k][j+k][0]--; if(!st.se && check(i+k,j-k,1)) ans[i+k][j-k][1]--; } } } cout << res[0].size() << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...