求调 除#2 全 WA
  • 板块P1191 矩形
  • 楼主tzzl3035
  • 当前回复0
  • 已保存回复0
  • 发布时间2025/1/31 19:39
  • 上次更新2025/2/1 13:13:21
查看原帖
求调 除#2 全 WA
1030559
tzzl3035楼主2025/1/31 19:39

rt

#include <bits/stdc++.h>
using pii = std::pair<int, int>;
int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(nullptr);
  int n; std::cin >> n;
  std::vector<int> f(n+3, 0);
  int ans = 0;
  for(int i = 1; i <= n; ++i) {
    std::string s; std::cin >> s;
    s = "-" + s;
    std::vector<pii> stk;
    for(int j = 1; j <= n; ++j) {
      if(s[j] == 'B') {
        stk.clear();
        f[j] = 0; continue;
      }
      f[j] += 1;
      int tmp = 1;
      for(; stk.size() && stk.back().first >= f[j]; ) {
        tmp += stk.back().second;
        stk.pop_back();
      }
      stk.push_back({f[j], tmp});
      ans += f[j] * tmp;
    }
  }
  std::cout << ans;
}
2025/1/31 19:39
加载中...