이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, m; bool flip, ans[1005][1005];
void solve(){
cin >> n >> m; flip = (n > m);
if (flip) swap(n, m);
int H = n / 2 + 1, L = m / 2 + 1;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
ans[i][j] = 0;
for (int i = 1; i < n - H + 1; i++)
for (int j = 1; j <= L; j++)
ans[i][j] = 1;
int lose = (m % 2 == 0) + 1, gain = n - H;
if (gain - lose > 0)
for (int i = H + 1; i <= n; i++)
for (int j = m - L + 1; j <= m; j++)
ans[i][j] = 1;
cout<<m + (n - H) + max(gain - lose, 0)<<endl;
if (flip)
for (int j = 1; j <= m; j++)
for (int i = n; i; i--)
cout<<(ans[i][j] ? '-' : '+')<<(i == 1 ? "\n" : "");
else
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cout<<(ans[i][j] ? '+' : '-')<<(j == m ? "\n" : "");
}
int main(){
int tc; cin >> tc;
while (tc--) solve();
}
# | 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... |