# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
919532 | AnarTz | Red-blue table (IZhO19_stones) | C++17 | 45 ms | 2384 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 <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
int ans,n,m,i,j,maxl,addl,needed,check,q,w,plus;
ans = 0;
cin >> n >> m;
char table[n][m];
bool bosoo;
if (n>m)
{
maxl = n;
addl = ((m-(m/2+1))*n)/(n/2+1);
bosoo = true;
memset(table,'+',sizeof table);
needed = n/2+1;
}else{
maxl = m;
addl = ((n-(n/2+1))*m)/(m/2+1);
bosoo = false;
memset(table,'-',sizeof table);
needed = m/2+1;
}
ans = maxl + addl;
cout << ans<<endl;
check = needed*addl;
q=0;
w=0;
while (check>0 && bosoo == false)
{
table[q][w]='+';
w++;
check--;
plus++;
if (plus==maxl/2+1)
{
q++;
plus=0;
}
if (w==maxl)
{
w=0;
}
}
while (check>0 && bosoo == true)
{
table[w][q]='-';
w++;
check--;
plus++;
if (plus==maxl/2+1)
{
q++;
plus=0;
}
if (w==maxl)
{
w=0;
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cout << table[i][j] << ' ';
}
cout << '\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... |