結果

問題 No.5025 Forest Fire
コンテスト
ユーザー butsurizuki
提出日時 2026-10-22 20:28:25
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
+ 504µs
コード長 1,096 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,799 ms
コンパイル使用メモリ 354,524 KB
実行使用メモリ 9,924 KB
スコア 149,774,446
最終ジャッジ日時 2026-10-24 14:46:48
合計ジャッジ時間 59,219 ms
ジャッジサーバーID
(参考情報)
judge5_0 / <nil>
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>

using namespace std;
using pi=pair<int,int>;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  cin >> n >> m;
  vector<string> s(n);
  for(auto &nx : s){cin >> nx;}
  vector<vector<pi>> l1(2*n+5),l2(2*n+5);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      l1[i+j].push_back({i,j});
      l2[i+n-j].push_back({i,j});
    }
  }

  vector<pair<int,pi>> cand;
  for(auto &nx : l1[40]){
    cand.push_back({s[nx.first][nx.second],nx});
  }
  for(auto &nx : l2[40]){
    cand.push_back({s[nx.first][nx.second],nx});
  }
  for(auto &nx : l1[60]){
    cand.push_back({s[nx.first][nx.second],nx});
  }
  for(auto &nx : l2[60]){
    cand.push_back({s[nx.first][nx.second],nx});
  }

  vector<pi> vp;
  sort(cand.rbegin(),cand.rend());
  for(auto &nx : cand){
    if(vp.size()>=m){break;}
    if(s[nx.second.first][nx.second.second]>'0'){
      s[nx.second.first][nx.second.second]='0';
      vp.push_back(nx.second);
    }
  }

  cout << vp.size() << "\n";
  for(auto &nx : vp){
    cout << nx.first << " " << nx.second << "\n";
  }
  return 0;
}
0