結果

問題 No.3657 Gathering Stones
コンテスト
ユーザー UT0911
提出日時 2026-08-30 14:50:30
言語 C++17
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 527µs
コード長 2,955 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,161 ms
コンパイル使用メモリ 277,912 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-30 14:50:50
合計ジャッジ時間 5,594 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 57
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:39:14: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' [-Wc++20-extensions]
   39 | void arrOut2(auto A){
      |              ^~~~

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using namespace std::chrono;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define ALL(x) (x).begin(), (x).end()
#define coutY cout << "Yes" << endl;
#define coutN cout << "No" << endl;
#define arrIn(arr, start, N) for (ll i = (start); i < (N); ++i) cin >> arr[i];
#define arrOut(arr, start, N) for  (ll i = (start); i < (N); ++i) { cout << arr[i]; if(i==(N)-1) cout << endl; else cout << " "; }
#define UNIQUE(A) sort(ALL(A)); A.erase(unique(ALL(A)),A.end());
#define mod9 998244353
#define mod1 1000000007
const int intM=1e9;
const ll llM=1e18;
void yn(bool tf) { cout << (tf ? "Yes" : "No") << endl; }
void YN(bool tf) { cout << (tf ? "YES" : "NO") << endl; }
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string abc="abcdefghijklmnopqrstuvwxyz";
vi dx={0,-1,1,0};
vi dy={-1,0,0,1};
vi ddx={-1,0,1,-1,1,-1,0,1};
vi ddy={-1,-1,-1,0,0,1,1,1};

template<class T>
using priority_queueR = priority_queue<T, vector<T>, greater<T>>;

//cout << fixed << setprecision(20) <<

void arrOut2(auto A){
  for(auto x:A){
    for(auto y:x){
      cout << y << " ";
    }
    cout << endl;
  }
}

bool kaibun(string S){
  string T=S;
  reverse(ALL(S));
  return S==T;
}

int ketawa(int x){
  string S=to_string(x);
  int sum=0;
  int len=S.size();
  for(int i=0;i<len;i++){
    sum+=(int)(S[i]-'0');
  }
  return sum;
}

ll Power(ll a,ll b,ll m){
  ll ans=1,p=a;
  for(ll i=0;i<60;i++){
    if(b&(1LL<<i)){
      ans=(ans*p)%m;
    }
    p=(p*p)%m;
  }
  return ans;
}

ll ncr(ll n,ll r,ll m){
  if(r<=0||r>n)return 0;
  ll bunshi=1;
  for(ll i=1;i<=n;i++)bunshi=(bunshi*i)%m;

  ll bunbo=1;
  for(ll i=1;i<=r;i++)bunbo=(bunbo*i)%m;
  for(ll i=1;i<=n-r;i++)bunbo=(bunbo*i)%m;

  return (bunshi*Power(bunbo,m-2,m))%m;
}

// auto start = high_resolution_clock::now();

// bool CheckTime(auto limit,auto eps){
//   auto end = high_resolution_clock::now();
//   return  duration_cast<milliseconds>(end - start).count()<limit-eps;
// }

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int N,M;
  cin >> N >> M;
  vs S(N);
  for(int i=0;i<N;i++)cin >> S[i];
  vi count(M,0);
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(S[i][j]=='#')count[j]++;
    }
  }
  
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(count[j]>i)S[i][j]='#';
      else S[i][j]='.';
    }
  }
  //arrOut(count,0,M);
  //for(int i=0;i<N;i++)cout << S[i] << endl;
  
  vi count2(N,0);
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(S[i][j]=='#')count2[i]++;
    }
  }
  
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(count2[i]>j)S[i][j]='#';
      else S[i][j]='.';
    }
  }
  
  for(int i=0;i<N;i++)cout << S[i] << endl;
  
  
  
  return 0;
}
0