# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168077 | tincamatei | Red-blue table (IZhO19_stones) | C++14 | 30 ms | 2296 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000;
char matr[MAX_N][MAX_N];
int main() {
int T, N, M;
scanf("%d", &T);
while(T--) {
int best = 0, bestFR = -1, bestFC = -1;
scanf("%d%d", &N, &M);
int reqPerRow = M / 2 + 1, reqPerCol = N / 2 + 1;
int freePerRow = M - reqPerRow;
for(int fixedRows = 0; fixedRows <= N; ++fixedRows)
for(int fixedCols = 0; fixedCols <= M; ++fixedCols) {
int reqCol = max(0, reqPerCol - (N - fixedRows));
int reqRow = max(0, reqPerRow - (M - fixedCols));
if((long long)reqRow * fixedRows + (long long)reqCol * fixedCols <= (long long)fixedCols * fixedRows && fixedRows + fixedCols > best) {
best = fixedRows + fixedCols;
bestFR = fixedRows;
bestFC = fixedCols;
}
}
int lastP = 0;
for(int l = 0; l < N; ++l)
for(int c = 0; c < M; ++c)
matr[l][c] = '-';
int reqRow = max(0, reqPerRow - (M - bestFC));
for(int l = 0; l < bestFR; ++l) {
for(int c = bestFC; c < M; ++c)
matr[l][c] = '+';
for(int c = 0; c < bestFC && c < reqRow; ++c) {
matr[l][lastP] = '+';
lastP = (lastP + 1) % bestFC;
}
}
printf("%d\n", best);
for(int l = 0; l < N; ++l) {
for(int c = 0; c < M; ++c)
fputc(matr[l][c], stdout);
printf("\n");
}
}
return 0;
}
Compilation message (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... |