結果

問題 No.459 C-VS for yukicoder
ユーザー algon_320algon_320
提出日時 2016-12-10 12:59:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 2,818 bytes
コンパイル時間 1,852 ms
コンパイル使用メモリ 180,000 KB
実行使用メモリ 6,156 KB
最終ジャッジ日時 2023-08-19 09:17:35
合計ジャッジ時間 5,531 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9*2; const long long INFLL=1e18*2;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.second >> p.first; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------

void output_pack(vi &a) {
    vector<string> res(3,"...");
    REP(i,3) {
        int c=a[i];
        REP(j,c) {
            res[2-j][i]='#';
        }
    }
    cout<<res<<endl;
}
signed main() {
    int H,W,N;
    cin>>H>>W>>N;
    vector<string> S(H);
    vi C(N);
    cin>>S>>C;

    vi sum(W,0);
    REP(j,W) {
        REP(i,H) {
            sum[j]+=(S[i][j]=='#');
        }
    }

    // i番目のパックは左からans[i][0],ans[i][1],ans[i][2]個 (個数の合計がans[i][3])
    vector<vector<int>> ans(N,vi(4,0));
    vector<pii> tmp(N);
    REP(i,N) {
        tmp[i].first=C[i];
        tmp[i].second=i;
    }
    sort(ALL(tmp));

    REP(t,N) {
        int i=tmp[t].second;
        int c=tmp[t].first;
        REP(j,3) {
            if(sum[c+j]>0) {
                ans[i][j]++;
                ans[i][3]++;
                sum[c+j]--;
                break;
            }
        }
    }

    REP(i,N) {
        int c=C[i];
        REP(j,3) {
            if(sum[c+j]==0) continue;
            // 余っている
            if(ans[i][j]<3) {
                // 余裕のある分だけ取る
                int t=3-ans[i][j];
                if(sum[c+j]<=t) {
                    ans[i][j]+=sum[c+j];
                    ans[i][3]+=sum[c+j];
                    sum[c+j]-=sum[c+j];
                }
                else {
                    ans[i][j]+=t;
                    ans[i][3]+=t;
                    sum[c+j]-=t;
                }
            }
        }
    }

    REP(i,N) {
        output_pack(ans[i]);
    }
    return 0;
}
0