結果

問題 No.459 C-VS for yukicoder
ユーザー algon_320algon_320
提出日時 2016-12-10 01:12:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 3,366 bytes
コンパイル時間 2,202 ms
コンパイル使用メモリ 176,508 KB
実行使用メモリ 5,824 KB
最終ジャッジ日時 2023-08-19 06:45:34
合計ジャッジ時間 12,994 ms
ジャッジサーバーID
(参考情報)
judge14 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;}
//------------------------------------------------------------------------------

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

    vi sum(W,0),pack(W,0),div(W,0);
    REP(j,W) {
        REP(i,H) {
            sum[j]+=(S[i][j]=='#');
        }
    }
    FORE(c,C) {
        REP(i,3) {
            pack[c+i]++;
        }
    }
    REP(i,W) {
        div[i]=sum[i]/pack[i];
    }

    // i番目のパックは左からans[i][0],ans[i][1],ans[i][2]個 (個数の合計がans[i][3])
    vector<vector<int>> ans(N,vi(4,0));

    REP(i,N) {
        int c=C[i];
        REP(j,3) {
            if(div[c+j]==0) continue;
            if(sum[c+j]<div[c+j]) {
                ans[i][j]+=sum[c+j];
                ans[i][3]+=sum[c+j];
                sum[c+j]=0;
            }
            else {
                ans[i][j]+=div[c+j];
                ans[i][3]+=div[c+j];
                sum[c+j]-=div[c+j];
            }
        }
    }

    REP(i,N) {
        if(ans[i][3]!=0) continue;
        int c=C[i];
        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]=0;
                }
                else {
                    ans[i][j]+=t;
                    ans[i][3]+=t;
                    sum[c+j]-=t;
                }
            }
        }
    }

    REP(i,W) if(sum[i]>0) {
        cout<<"WA"<<endl;
        return 0;
    }

    REP(i,N) {
        vector<string> p=create_pack(ans[i]);
        cout<<p<<endl;
    }
    return 0;
}
0