Submission #780249

#TimeUsernameProblemLanguageResultExecution timeMemory
780249mychecksedadDango Maker (JOI18_dango_maker)C++17
13 / 100
1 ms468 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; typedef long long int ll; #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() const int N = 1E7+100, M = 1e5+10, K = 20; int n, m; string s[4000]; bitset<3> g[N][2]; bitset<N> v[2]; bitset<N> vis[2]; vector<vector<int>> arr; pair<int, int> dfs(int x, int p){ pair<int, int> ans = {1, 0}; // cout <<x << ' ' << p << '\n'; vis[p][x] = 1; for(int y = 0; y < 3; ++y){ if(!g[x][p][y]) continue; pair<int, int> u = {arr[p][y]+x, 1-p}; if(vis[u.second][u.first]) continue; auto dp = dfs(u.first, u.second); ans.first += dp.second; ans.second += max(dp.first, dp.second); } return ans; } void solve(){ cin >> n >> m; arr = { { 0, m-1, 2*m-2 }, { 0, -m+1, -2*m+2 } }; for(int i = 0; i < n; ++i) cin >> s[i]; for(int i = 0; i < n; ++i){ for(int j = 0; j < m; ++j){ if(i < n - 2){ int x = i*m+j; if(s[i][j] == 'R' && s[i+1][j] == 'G' && s[i+2][j] == 'W'){ if(v[1][x]) g[x][0][0] = 1, g[x][1][0] = 1; if(v[1][x+m]) g[x][0][1] = 1, g[x+m-1][1][1] = 1; if(v[1][x+m+m]) g[x][0][2] = 1, g[x+2*m-2][1][2] = 1; v[0][x] = v[0][x+m] = v[0][x+m+m] = 1; } } if(j < m-2){ int x = i*m+j; if(s[i][j] == 'R' && s[i][j+1] == 'G' && s[i][j+2] == 'W'){ if(v[0][x]) g[x][1][0] = 1, g[x][0][0] = 1; if(v[0][x+1]) g[x][1][1] = 1, g[x+1-m][0][1] = 1; if(v[0][x+2]) g[x][1][2] = 1, g[x+2-2*m][0][2] = 1; v[1][x] = v[1][x+1] = v[1][x+2] = 1; } } } } int ans = 0; for(int i = 0; i < n; ++i){ for(int j = 0; j < m; ++j){ if(s[i][j] != 'R') continue; if(!vis[0][i*m+j]&&v[0][i*m+j]){ auto dp = dfs(i*m+j, 0); ans += max(dp.first, dp.second); }else if(!vis[1][i*m+j]&&v[1][i*m+j]){ auto dp = dfs(i*m+j, 1); ans += max(dp.first, dp.second); } } } cout << ans; } int main(){ cin.tie(0); ios::sync_with_stdio(0); int T = 1, aa; // cin >> T;aa=T; while(T--){ // cout << "Case #" << aa-T << ": "; solve(); cout << '\n'; } return 0; }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:94:14: warning: unused variable 'aa' [-Wunused-variable]
   94 |   int T = 1, aa;
      |              ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...