답안 #968140

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968140 2024-04-23T07:56:39 Z berr 조교 (CEOI16_popeala) C++17
26 / 100
685 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 2e4+30;

int r[N][N];

void solve(){
    int n, t, s; cin >> n >> t >> s;
    vector<int> v(t);
    vector<vector<array<int, 2>>> g(t+1);
    vector dis(t+1, vector(s+2, (int)2e9));
    
    for(auto &i: v) cin >> i;

    vector<string> se(n);

    for(auto &i: se){
        cin >> i;
        int k=i[0]-'0';

        for(int l=1; l<t; l++){
            if(i[l]=='0'){
                for(int j=l-k; j<l; j++){
                    for(int g=j; g<l; g++){
                        r[j][g]++;
                    }
                }
                k=0;
            }
            else k++;
        }

        if(k){
            for(int j=t-k; j<t; j++){
                for(int g=j; g<t; g++){
                    r[j][g]++;
                }
            }        
        }
    } 

    for(int i=1; i<t; i++) v[i] += v[i-1];

    for(int i=0; i<t; i++){
        int ek=0;
        if(i>0) ek=v[i-1];

        for(int l=i+1; l<t; l++){

            g[i].push_back({l, (v[l-1]-ek)*r[i][l-1]});
        }
 
        g[i].push_back({t, (v[t-1]-ek)*r[i][t-1]});
    }

    priority_queue<array<int, 3>> pq;

    dis[0][0]=0;

    for(int i=0; i<t; i++){
        for(int l=0; l<s; l++){
            if(dis[i][l]==2e9) continue;
            int cos = dis[i][l];
            int ed = l;
            int v = i;
        
            for(auto [i, c]: g[v]){
                if(ed+1 <= s && cos+c < dis[i][ed+1]){
                    dis[i][ed+1]=cos+c;
                }
            }
        }
    }

    for(int i=1; i<=s; i++) cout<<dis[t][i]<<"\n";
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    /*freopen("popeala.in", "r", stdin);
    freopen("popeala.out", "w", stdout);
*/
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 40792 KB Output is correct
2 Correct 14 ms 40796 KB Output is correct
3 Correct 13 ms 40792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 192 ms 195668 KB Output is correct
2 Correct 340 ms 221516 KB Output is correct
3 Correct 685 ms 261880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 20 ms 40792 KB Output is correct
4 Correct 14 ms 40796 KB Output is correct
5 Correct 13 ms 40792 KB Output is correct
6 Correct 192 ms 195668 KB Output is correct
7 Correct 340 ms 221516 KB Output is correct
8 Correct 685 ms 261880 KB Output is correct
9 Runtime error 238 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -