| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 465184 | kilikuma | Colouring a rectangle (eJOI19_colouring) | C++14 | 2082 ms | 460 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define long long long
bool etatBas[30];
int nbLigs, nbCols;
long diagBas[30], diagHaut[30];
long miniCur = (1e12);
long mini(long a, long b) {
if (a<b)return a; else return b;
}
void recur(int niveau) {
if( niveau > (nbLigs+nbCols-1)) {
// code important
long tot = 0;
bool A[13][13] = {false};
for (int diag = 1; diag <= nbLigs; diag ++) {
if (etatBas[diag]) {
tot += diagBas[diag];
int lig = diag; int col = nbCols;
while ((lig>=1) && (col>=1)) {
A[lig][col] = true;
lig --; col --;
}
}
}int lo = nbLigs+1;
for (int diag = nbCols-1; diag >= 1; diag --) {
if (etatBas[lo]) {
tot += diagBas[lo];
int lig = nbLigs; int col = diag;
while ((lig>=1) && (col>=1)) {
A[lig][col] = true;
lig --; col --;
}
}
lo ++;
}
// if (etatBas[1] && etatBas[3]){
// }
for (int diag = 1; diag <= nbLigs; diag ++) {
bool cond = true;
int lig = diag; int col = 1;
while ((lig >=1)&&(col<=nbCols)) {
if (!A[lig][col]) cond = false;
A[lig][col] = true;
lig --; col ++;
}
if (!cond) tot += diagHaut[diag];
}
for (int diag = 2; diag <= nbCols; diag ++) {
bool cond = true;
int lig = nbLigs; int col = diag;
while ((lig >=1)&&(col<=nbCols)) {
if (!A[lig][col]) cond = false;
A[lig][col] = true;
lig --; col ++;
}
if (!cond) tot += diagHaut[diag-1+nbLigs];
}
miniCur = mini(miniCur, tot);
return ;
}
else {
etatBas[niveau+1] = false;
recur(niveau+1);
etatBas[niveau+1] =true;
recur(niveau+1);
etatBas[niveau+1] = false;
}
return;
}
int main() {
scanf("%d%d",&nbLigs,&nbCols);
for (int i = 1; i <= nbLigs+nbCols-1;i ++) cin >> diagBas[i];
for (int i = 1; i <= nbLigs+nbCols-1;i ++) cin >> diagHaut[i];
recur(0);
cout << miniCur;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
