답안 #595375

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595375 2022-07-13T16:54:13 Z AdamGS Coins (LMIO19_monetos) C++17
8.37512 / 100
22 ms 1236 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=307;
int T[LIM], pref[LIM], suf[LIM];
pair<int,int>dp[LIM][LIM];
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int t, n, k1, k2;
  cin >> t >> n >> k1 >> k2;
  rep(i, n) dp[0][i].nd=n;
  rep(i, n) {
    rep(j, n) {
      cin >> T[j];
      pref[j+1]=T[j]+pref[j];
    }
    for(int j=n-1; j>=0; --j) suf[j]=1-T[j]+suf[j+1];
    rep(j, n+1) {
      dp[i+1][j]={dp[i][j].st+pref[j]+suf[j], j};
    }
    for(int j=n-1; j>=0; --j) dp[i+1][j]=min(dp[i+1][j], dp[i+1][j+1]);
  }
  vector<int>V;
  int akt=0;
  for(int i=n; i; --i) {
    akt=dp[i][akt].nd;
    V.pb(akt);
  }
  reverse(all(V));
  int sum=0;
  rep(i, n) rep(j, n) if(j>=V[i]) ++sum;
  if(sum!=n*n/2) rep(i, n) V[i]=n/2;
  rep(i, n) {
    rep(j, n) cout << (j>=V[i]) << " ";
    cout << '\n';
  }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 340 KB K = 25
2 Incorrect 1 ms 340 KB K = 648
3 Incorrect 12 ms 1196 KB K = 21146
4 Partially correct 18 ms 1136 KB K = 23239
5 Partially correct 22 ms 1232 KB K = 18430
6 Partially correct 21 ms 1204 KB K = 22273
7 Incorrect 14 ms 1236 KB K = 22837
8 Partially correct 16 ms 1236 KB K = 20045
9 Partially correct 14 ms 1164 KB K = 21031
10 Incorrect 18 ms 1216 KB K = 22645