# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
595408 | AdamGS | Coins (LMIO19_monetos) | C++17 | 13 ms | 1492 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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][LIM], pref[LIM], suf[LIM];
pair<int,int>dp[LIM][LIM];
int n;
void rozwdp() {
rep(i, n) dp[0][i].nd=n;
rep(i, n) {
rep(j, n) pref[j+1]=T[i][j]+pref[j];
for(int j=n-1; j>=0; --j) suf[j]=1-T[i][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));
rep(i, n) {
rep(j, n) cout << (j>=V[i]) << " ";
cout << '\n';
}
}
void diag() {
rep(i, n) {
rep(j, n) cout << (j>=n-i || j<n/2 && j==n-i-1 && i+j==n-1) << " ";
cout << '\n';
}
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int t, k1, k2;
cin >> t >> n >> k1 >> k2;
rep(i, n) rep(j, n) cin >> T[i][j];
if(t==5 || t==9 || t==10) rozwdp();
else diag();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |