记录编号 359323 评测结果 AAAAAAAAAA
题目名称 [Nescafé 20] 玉蟾宫 最终得分 100
用户昵称 Gravatarsxysxy 是否通过 通过
代码语言 C++ 运行时间 0.107 s
提交时间 2016-12-22 08:08:40 内存使用 15.83 MiB
显示代码纯文本
  1. #include <cstdio>
  2. #include <cstring>
  3. #include <cstdarg>
  4. #include <list>
  5. #include <queue>
  6. #include <vector>
  7. #include <cctype>
  8. using namespace std;
  9. namespace IO
  10. {
  11. char buf[1<<18], *fs, *ft;
  12. inline char readc()
  13. {
  14. return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<18,stdin),fs==ft))?0:*fs++;
  15. }
  16. inline int fast_read()
  17. {
  18. int r;
  19. char c;
  20. bool s = false;
  21. while(c = readc())
  22. {
  23. if(c >= '0' && c <= '9')
  24. {
  25. r = c^0x30;
  26. break;
  27. }else if(c == '-')s = true;
  28. }
  29. while(isdigit(c = readc()))
  30. r = (r<<3)+(r<<1)+(c^0x30);
  31. return s?-r:r;
  32. }
  33. }using IO::fast_read;using IO::readc;
  34. #define MAXN 1001
  35. int field[MAXN][MAXN], len[MAXN][MAXN], left[MAXN][MAXN], right[MAXN][MAXN];
  36. void work()
  37. {
  38. int m, n; m = fast_read(); n = fast_read();
  39. for(int i = 0; i < m; i++)for(int j = 0; j < n; j++)
  40. {
  41. char c = readc();
  42. while(c != 'F' && c != 'R')c = readc();
  43. field[i][j] = c == 'F'? 0:1;
  44. }
  45. int ans = 0;
  46. for(int i = 0; i < m; i++)
  47. {
  48. int lo = -1, ro = n;
  49. for(int j = 0; j < n; j++) //calc lo
  50. {
  51. if(field[i][j])len[i][j] = left[i][j] = 0, lo = j;
  52. else
  53. {
  54. len[i][j] = i?(len[i-1][j]+1):1;
  55. left[i][j] = i?max(lo+1, left[i-1][j]):lo+1;
  56. }
  57. }
  58. for(int j = n-1; ~j; j--)
  59. {
  60. if(field[i][j])right[i][j] = n, ro = j;
  61. else
  62. {
  63. right[i][j] = i?min(right[i-1][j], ro-1):ro-1;
  64. ans = max(ans, len[i][j]*(right[i][j]-left[i][j]+1));
  65. }
  66. }
  67. }
  68. printf("%d\n", ans*3);
  69. }
  70.  
  71. int main()
  72. {
  73. freopen("jademoon.in", "r", stdin);
  74. freopen("jademoon.out", "w", stdout);
  75. //int T;scanf("%d", &T);
  76. //while(T--)
  77. work();
  78. return 0;
  79. }