Submission #254707

#TimeUsernameProblemLanguageResultExecution timeMemory
254707egekabasDango Maker (JOI18_dango_maker)C++14
13 / 100
1 ms384 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<int, int> pii; typedef pair<ld, ld> pld; int n, m; int a[3009][3009]; int cl(int x, int y){ return(a[x][y] == 1 && a[x][y+1] == 2 && a[x][y+2] == 3); } int cd(int x, int y){ return(a[x][y] == 1 && a[x+1][y] == 2 && a[x+2][y] == 3); } vector<pii> v; int sf(pii x, pii y){ if(x.ff + x.ss != y.ff + y.ss) return x.ff + x.ss < y.ff + y.ss; return x.ss > y.ss; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); cin >> n >> m; string s; for(int i = 0; i < n; ++i){ cin >> s; for(int j = 0; j < m; ++j){ if(s[j] == 'R') a[i][j] = 1; else if(s[j] == 'G') a[i][j] = 2; else a[i][j] = 3; v.pb({i, j}); } } sort(v.begin(), v.end(), sf); int ans = 0; for(auto u : v){ int i = u.ff; int j = u.ss; if(cd(i, j)){ ++ans; a[i][j] = a[i+1][j] = a[i+2][j] = 0; } if(cl(i, j)){ ++ans; a[i][j] = a[i][j+1] = a[i][j+2] = 0; } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...