結果

問題 No.459 C-VS for yukicoder
ユーザー どららどらら
提出日時 2016-12-10 13:06:58
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,784 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 93,152 KB
実行使用メモリ 4,876 KB
最終ジャッジ日時 2023-08-19 09:18:57
合計ジャッジ時間 7,010 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 24 ms
4,876 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 4 ms
4,376 KB
testcase_26 AC 5 ms
4,380 KB
testcase_27 AC 5 ms
4,376 KB
testcase_28 AC 4 ms
4,380 KB
testcase_29 AC 10 ms
4,376 KB
testcase_30 AC 5 ms
4,376 KB
testcase_31 WA -
testcase_32 AC 2 ms
4,380 KB
testcase_33 WA -
testcase_34 AC 7 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 8 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 WA -
testcase_39 AC 2 ms
4,380 KB
testcase_40 WA -
testcase_41 AC 2 ms
4,380 KB
testcase_42 WA -
testcase_43 AC 7 ms
4,380 KB
testcase_44 WA -
testcase_45 AC 2 ms
4,384 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 7 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 WA -
testcase_51 AC 2 ms
4,380 KB
testcase_52 WA -
testcase_53 AC 2 ms
4,376 KB
testcase_54 WA -
testcase_55 AC 3 ms
4,380 KB
testcase_56 AC 6 ms
4,380 KB
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 7 ms
4,376 KB
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

struct ST {
  int p;
  int i;
};
bool operator<(const ST& a, const ST& b){
  return a.p < b.p;
}

int main(){
  ios::sync_with_stdio(false);
  int H, W, N;
  cin >> H >> W >> N;
  vector<string> v;
  vector<int> w;
  vector<ST> st;

  rep(i,H){
    string s;
    cin >> s;
    v.push_back(s);
  }
  rep(i,N){
    int a;
    cin >> a;
    w.push_back(a);
    st.push_back((ST){a,i});
  }
  vector<int> num(W+5,0);
  rep(i,H){
    rep(j,W){
      if(v[i][j]=='#'){
        num[j]++;
      }
    }
  }

  vector<int> cnt(W+5,0);
  rep(i,N){
    cnt[w[i]]++;
    cnt[w[i]+1]++;
    cnt[w[i]+2]++;
  }

  vector<string> ret(N,"");
  sort(ALLOF(st));
  rep(i,N){
    int p1 = st[i].p;
    int p2 = st[i].p+1;
    int p3 = st[i].p+2;

    int ret1 = 0, ret2 = 0, ret3 = 0;
    bool f1 = false, f2 = false, f3 = false;
    if(num[p1]==0 || num[p1] < cnt[p1]) f1 = true;
    if(num[p2]==0 || num[p2] < cnt[p2]) f2 = true;
    if(num[p3]==0 || num[p3] < cnt[p3]) f3 = true;

    if(f1 && f2 && f3){
      if(num[p1]>0) ret1++;
      else if(num[p2]>0) ret2++;
      else ret3++;
    }else{
      if(num[p1]>0){
        if(num[p1] >= cnt[p1]) ret1 = min(3,(num[p1] + cnt[p1]-1)/cnt[p1]);
        else ret1 = 1;
      }
      if(num[p2]>0){
        if(num[p2] >= cnt[p2]) ret2 = min(3,(num[p2] + cnt[p2]-1)/cnt[p2]);
        else ret2 = 1;
      }
      if(num[p3]>0){
        if(num[p3] >= cnt[p3]) ret3 = min(3,(num[p3] + cnt[p3]-1)/cnt[p3]);
        else ret3 = 1;
      }
    }

    //cout << i << " " << p1 << " " << ret1 << " " << ret2 << " " << ret3 << endl;
    
    stringstream ss;
    if(ret1>=3) ss << "#"; else ss << ".";
    if(ret2>=3) ss << "#"; else ss << ".";
    if(ret3>=3) ss << "#"; else ss << ".";
    ss << endl;
    if(ret1>=2) ss << "#"; else ss << ".";
    if(ret2>=2) ss << "#"; else ss << ".";
    if(ret3>=2) ss << "#"; else ss << ".";
    ss << endl;
    if(ret1>=1) ss << "#"; else ss << ".";
    if(ret2>=1) ss << "#"; else ss << ".";
    if(ret3>=1) ss << "#"; else ss << ".";
    ss << endl;

    ret[st[i].i] = ss.str();
    
    if(ret1>0){ num[p1] -= ret1; }
    if(ret2>0){ num[p2] -= ret2; }
    if(ret3>0){ num[p3] -= ret3; }
    cnt[p1]--;
    cnt[p2]--;
    cnt[p3]--;

  }

  rep(i,N){
    cout << ret[i];
  }
  cout << endl;
  return 0;
}

0