# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
599095 | M_W | Red-blue table (IZhO19_stones) | C++17 | 90 ms | 1356 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;
char a[1010][1010];
int main(){
int T;
scanf("%d", &T);
while(T--){
int N, M, state = 0;
scanf("%d %d", &N, &M);
if(N > M){
state = 1;
swap(N, M);
}
for(int i = 1; i <= N; i++){
for(int j = 1; j <= M; j++) a[i][j] = state ? '+' : '-';
}
for(int i = 1; i <= N - (2 - N % 2); i++){
for(int j = (i - 1) % 2; j <= M; j+= 2){
a[i][j] = state ? '-' : '+';
}
}
int ans = 0;
for(int i = 1; i <= N; i++){
int red = 0, blue = 0;
for(int j = 1; j <= M; j++){
if(a[i][j] == '+') red++;
else blue++;
}
if(state && blue > red) ans++;
else if(!state && red > blue) ans++;
}
for(int i = 1; i <= M; i++){
int red = 0, blue = 0;
for(int j = 1; j <= N; j++){
if(a[j][i] == '+') red++;
else blue++;
}
if(!state && blue > red) ans++;
else if(state && red > blue) ans++;
}
printf("%d\n", ans);
for(int i = 1; i <= N; i++){
for(int j = 1; j <= M; j++){
printf("%c", state ? a[j][i] : a[i][j]);
}
printf("\n");
}
}
}
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... |