제출 #99435

#제출 시각아이디문제언어결과실행 시간메모리
99435psmaoDango Maker (JOI18_dango_maker)C++14
0 / 100
219 ms263168 KiB
#include <bits/stdc++.h> using namespace std; #define fo(i,s,t) for(int i = s; i <= t; ++ i) #define fd(i,s,t) for(int i = s; i >= t; -- i) #define bf(i,s) for(int i = head[s]; i; i = e[i].next) #define mp make_pair #define fi first #define se second #define pii pair<int,int> #define pb push_back #define VI vector<int> #define sf scanf #define pf printf #define fp freopen #define SZ(x) ((int)(x).size()) #ifdef MPS #define D(x...) printf(x) #else #define D(x...) #endif typedef long long ll; typedef double db; typedef unsigned long long ull; const int inf = 1<<30; const ll INF = 1ll<<60; const db Inf = 1e20; const db eps = 1e-9; void gmax(int &a,int b){a = (a > b ? a : b);} void gmin(int &a,int b){a = (a < b ? a : b);} const int maxn = 3005; int n, m, p[maxn][maxn][2]; int b[maxn*maxn*2], s0, s1; VI t[maxn][maxn]; char a[maxn][maxn]; VI adj[maxn*maxn*2]; void link(int u, int v) {adj[u].pb(v);} bool color(int x, int c=0) { b[x] = c; if(c == 0) s0 ++; else s1 ++; for(auto p : adj[x]) if(b[p] == c) return false; else if(b[p] == -1) color(p, c^1); return true; } int main() { #ifdef MPS fp("1.in","r",stdin); fp("1.out","w",stdout); #endif sf("%d%d",&n,&m); fo(i,1,n) sf("%s",a[i]+1); int tot = 0; fo(i,1,n) fo(j,1,m) fo(k,0,1) p[i][j][k] = ++ tot; fo(i,1,n) fo(j,1,m) if(a[i][j] == 'R') { continue; if(j+2 <= m && a[i][j+1] == 'G' && a[i][j+2] == 'W') { t[i][j].pb(p[i][j][0]); if(i>1 && i < n && a[i-1][j+1] == 'R' && a[i+1][j+1] == 'W') link(p[i][j][0], p[i-1][j+1][1]); if(i>2 && a[i-2][j+2] == 'R' && a[i-1][j+2] == 'G') link(p[i][j][0], p[i-2][j+2][1]); if(i <= n-2 && a[i+1][j] == 'G' && a[i+2][j] == 'W') link(p[i][j][0], p[i][j][1]); } if(i+2 <= n && a[i+1][j] == 'G' && a[i+2][j] == 'W') { t[i][j].pb(p[i][j][1]); if(j>1 && j < m && a[i+1][j-1] == 'R' && a[i+1][j+1] == 'W') link(p[i][j][1], p[i+1][j-1][0]); if(j>2 && a[i+2][j-2] == 'R' && a[i+2][j-1] == 'G') link(p[i][j][1], p[i+2][j-2][0]); if(j <= m-2 && a[i][j+1] == 'G' && a[i][j+2] == 'W') link(p[i][j][1], p[i][j][0]); } } return 0; int ans = 0; memset(b,-1,sizeof(b)); fo(i,1,n) fo(j,1,m) for(auto p: t[i][j]) if(b[p] == -1) { s0 = s1 = 0; if(color(p)) ans += max(s0, s1); } pf("%d\n",ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:57:4: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  sf("%d%d",&n,&m);
    ^
dango_maker.cpp:58:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fo(i,1,n) sf("%s",a[i]+1);
              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...