結果
問題 | No.348 カゴメカゴメ |
ユーザー | LayCurse |
提出日時 | 2016-02-26 22:47:33 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 129 ms / 2,000 ms |
コード長 | 3,723 bytes |
コンパイル時間 | 1,455 ms |
コンパイル使用メモリ | 162,524 KB |
実行使用メモリ | 145,972 KB |
最終ジャッジ日時 | 2024-09-22 22:17:17 |
合計ジャッジ時間 | 5,770 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 98 ms
97,328 KB |
testcase_01 | AC | 13 ms
40,408 KB |
testcase_02 | AC | 95 ms
82,052 KB |
testcase_03 | AC | 73 ms
43,208 KB |
testcase_04 | AC | 13 ms
36,492 KB |
testcase_05 | AC | 13 ms
36,488 KB |
testcase_06 | AC | 13 ms
40,268 KB |
testcase_07 | AC | 13 ms
40,268 KB |
testcase_08 | AC | 12 ms
38,212 KB |
testcase_09 | AC | 13 ms
40,140 KB |
testcase_10 | AC | 13 ms
40,136 KB |
testcase_11 | AC | 13 ms
40,268 KB |
testcase_12 | AC | 15 ms
41,408 KB |
testcase_13 | AC | 14 ms
40,616 KB |
testcase_14 | AC | 13 ms
40,300 KB |
testcase_15 | AC | 129 ms
145,972 KB |
testcase_16 | AC | 13 ms
40,264 KB |
testcase_17 | AC | 14 ms
40,396 KB |
testcase_18 | AC | 14 ms
40,392 KB |
testcase_19 | AC | 13 ms
40,264 KB |
testcase_20 | AC | 14 ms
40,404 KB |
testcase_21 | AC | 13 ms
40,268 KB |
testcase_22 | AC | 13 ms
40,264 KB |
testcase_23 | AC | 71 ms
50,436 KB |
testcase_24 | AC | 71 ms
52,224 KB |
testcase_25 | AC | 72 ms
50,044 KB |
testcase_26 | AC | 69 ms
48,476 KB |
testcase_27 | AC | 71 ms
50,576 KB |
testcase_28 | AC | 71 ms
52,996 KB |
testcase_29 | AC | 71 ms
49,900 KB |
testcase_30 | AC | 73 ms
53,384 KB |
testcase_31 | AC | 71 ms
50,492 KB |
testcase_32 | AC | 71 ms
49,696 KB |
testcase_33 | AC | 19 ms
43,724 KB |
testcase_34 | AC | 18 ms
41,344 KB |
testcase_35 | AC | 18 ms
41,272 KB |
testcase_36 | AC | 19 ms
41,296 KB |
testcase_37 | AC | 19 ms
41,832 KB |
testcase_38 | AC | 19 ms
41,708 KB |
testcase_39 | AC | 19 ms
41,412 KB |
testcase_40 | AC | 19 ms
41,692 KB |
testcase_41 | AC | 19 ms
41,436 KB |
testcase_42 | AC | 18 ms
41,364 KB |
testcase_43 | AC | 14 ms
40,436 KB |
testcase_44 | AC | 14 ms
40,440 KB |
testcase_45 | AC | 14 ms
42,604 KB |
testcase_46 | AC | 14 ms
40,456 KB |
testcase_47 | AC | 14 ms
40,620 KB |
testcase_48 | AC | 14 ms
40,332 KB |
testcase_49 | AC | 14 ms
40,300 KB |
testcase_50 | AC | 14 ms
40,604 KB |
testcase_51 | AC | 14 ms
40,436 KB |
testcase_52 | AC | 13 ms
40,316 KB |
コンパイルメッセージ
main.cpp: In function ‘void reader(double*)’: main.cpp:15:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | void reader(double *x){scanf("%lf",x);} | ~~~~~^~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) #define mygc(c) (c)=getchar_unlocked() #define mypc(c) putchar_unlocked(c) #define ll long long #define ull unsigned ll void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} void reader(double *x){scanf("%lf",x);} int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;} template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);} template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);} template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);} void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);} void writer(double x, char c){printf("%.15f",x);mypc(c);} void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);} void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);} template<class T> void writerLn(T x){writer(x,'\n');} template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');} template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');} template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');} char memarr[17000000]; void *mem = memarr; #define MD 1000000007 int X, Y; char mp[1111][1111]; int dx[8] = {0,0,1,-1,1,1,-1,-1}; int dy[8] = {1,-1,0,0,1,-1,1,-1}; int nul(int a, int b, char f, char t, int d, int st[], int &sts){ int i,res = 0; if(a < 0 || b < 0 || a >= X || b >= Y) return res; if(mp[a][b] != f){ if(mp[a][b]=='x'){ st[sts++] = a*1111+b; mp[a][b] = 'y'; } return res; } mp[a][b] = t; res++; rep(i,d) res += nul(a+dx[i],b+dy[i],f,t,d,st,sts); return res; } int node; vector<int> edge[1111111]; int es[1111111], gain[1111111]; void gen_graph(int st[], int sts, int bef){ int i, j, k, g; int *sss = st + sts; int ssz; rep(k,sts){ i = st[k] / 1111; j = st[k] % 1111; if(mp[i][j] != 'y') continue; ssz = 0; g = nul(i,j,'y','.',8,sss,ssz); es[node] = 0; gain[node] = g; if(bef!=-1) edge[bef].push_back(node); node++; ssz = 0; nul(i,j,'.','@',4,sss,ssz); gen_graph(sss,ssz,node-1); } } int st[1111111], sts; int dp0[1111111], dp1[1111111]; int solve(int now, int bef){ int i, j, k; dp0[now] = 0; dp1[now] = gain[now]; rep(i,edge[now].size()){ j = edge[now][i]; if(j==bef) continue; solve(j, now); dp0[now] += dp1[j]; dp1[now] += dp0[j]; } dp1[now] = max(dp0[now], dp1[now]); return dp1[now]; } int main(){ int i, j, k; int res; reader(&X,&Y); X += 2; Y += 2; REP(i,1,X-1) reader(mp[i]+1); rep(i,Y) mp[0][i] = mp[X-1][i] = '.'; rep(i,X) mp[i][0] = mp[i][Y-1] = '.'; node = 1; sts = 0; nul(0,0,'.','@',4,st,sts); gen_graph(st, sts, 0); res = solve(0,-1); writerLn(res); return 0; }