Submission #716558

#TimeUsernameProblemLanguageResultExecution timeMemory
716558penguin133Dango Maker (JOI18_dango_maker)C++17
13 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int, int> #define pii pair<int, pi> #define fi first #define se second #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, m, dp[3005][3005], fl[3005][3005], fr[3005][3005]; char G[3005][3005]; int par[9000005]; pi sz[9000005]; inline int conv(int i, int j){ return (i - 1) * m + j; } int getr(int x){ return (par[x] == x ? x : par[x] = getr(par[x])); } void merge(int a, int b){ a = getr(a), b = getr(b); if(a == b)return; sz[a].fi += sz[b].fi, sz[a].se += sz[b].se; par[b] = a; } void solve(){ cin >> n >> m; for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin >> G[i][j], par[conv(i, j)] = conv(i, j); for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(G[i][j] == 'R' && G[i][j+1] == 'G' && G[i][j+2] == 'W'){ int x = conv(i, j); merge(x, x+1); merge(x, x+2); sz[getr(x)].fi++; } if(G[i][j] == 'R' && G[i+1][j] == 'G' && G[i+2][j] == 'W'){ int x = conv(i, j); merge(x, x+m); merge(x, x+m*2); sz[getr(x)].se++; } } } int ans = 0; for(int i=1;i<=n*m;i++){ ans += max(sz[getr(i)].fi, sz[getr(i)].se); sz[getr(i)] = {0, 0}; } cout << ans; } main(){ ios::sync_with_stdio(0);cin.tie(0); int tc = 1; //cin >> tc; for(int tc1=1;tc1<=tc;tc1++){ // cout << "Case #" << tc1 << ": "; solve(); } }

Compilation message (stderr)

dango_maker.cpp:60:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   60 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...