# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
308782 | nikatamliani | Red-blue table (IZhO19_stones) | C++14 | 60 ms | 2304 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
int T = 1;
cin >> T;
while(T--) {
int n, m;
cin >> n >> m;
bool swapped = 0;
if(n < m) {
swap(n, m);
swapped = true;
}
bool ans[n + 1][m + 1];
memset(ans, 0, sizeof ans);
int rows = n, columns = 0, need = m / 2 + 1, to = 0;
for(int i = 1; i <= m; ++i) {
int allPlus = min(need, m - i);
int rem = m - allPlus, can = n - n / 2 - 1;
if(allPlus + i * can / rows >= need) {
columns = i;
to = allPlus;
}
}
int prev = to + 1;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= to; ++j) {
ans[i][j] = 1;
}
int rem = need - to;
auto next = [&](int index) {
return 1 + (index == m ? to : index);
};
for(int j = prev; rem--; j = next(j)) {
prev = next(j);
ans[i][j] = 1;
}
}
cout << rows + columns << '\n';
if(!swapped) {
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
cout << (ans[i][j] ? '+' : '-');
}
cout << '\n';
}
} else {
for(int i = 1; i <= m; ++i) {
for(int j = 1; j <= n; ++j) {
cout << (ans[j][i] ? '-' : '+');
}
cout << '\n';
}
}
}
}
컴파일 시 표준 에러 (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... |