結果

問題 No.5025 Forest Fire
コンテスト
ユーザー butsurizuki
提出日時 2026-10-22 20:13:39
言語 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  
実行時間 1 ms / 2,000 ms
+ 953µs
コード長 1,360 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,275 ms
コンパイル使用メモリ 345,364 KB
実行使用メモリ 9,932 KB
スコア 161,529,843
最終ジャッジ日時 2026-10-24 14:45:32
合計ジャッジ時間 57,938 ms
ジャッジサーバーID
(参考情報)
judge2_0 / <nil>
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>

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

const char lim='4';

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<pi> vp;
  for(auto &nx : l1[50]){
    if(s[nx.first][nx.second]>lim){
      s[nx.first][nx.second]='0';
      vp.push_back(nx);
    }
  }
  for(auto &nx : l2[50]){
    if(s[nx.first][nx.second]>lim){
      s[nx.first][nx.second]='0';
      vp.push_back(nx);
    }
  }
  for(auto &nx : l1[25]){
    if(s[nx.first][nx.second]>lim){
      s[nx.first][nx.second]='0';
      vp.push_back(nx);
    }
  }
  for(auto &nx : l2[25]){
    if(s[nx.first][nx.second]>lim){
      s[nx.first][nx.second]='0';
      vp.push_back(nx);
    }
  }
  for(auto &nx : l1[75]){
    if(s[nx.first][nx.second]>lim){
      s[nx.first][nx.second]='0';
      vp.push_back(nx);
    }
  }
  for(auto &nx : l2[75]){
    if(s[nx.first][nx.second]>lim){
      s[nx.first][nx.second]='0';
      vp.push_back(nx);
    }
  }
  while(vp.size()>m){vp.pop_back();}
  cout << vp.size() << "\n";
  for(auto &nx : vp){
    cout << nx.first << " " << nx.second << "\n";
  }
  return 0;
}
0