#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
const int inf = 2e9;
const int N = 1e3 + 15;
int t, n, m, a[N][N], row[N], col[N];
inline void make_red(int i, int j) {
a[i][j] = 1, ++row[i], ++col[j];
}
inline void make_blue(int i, int j) {
a[i][j] = 0, --row[i], --col[j];
}
main() {
ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
cin >> t;
while(t--) {
int ans = 0;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= m; ++j)
a[i][j] = row[i] = col[j] = 0;
cin >> n >> m;
if(n >= m) {
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= m / 2 + 1; ++j)
make_red(i, j);
}
else {
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= m; ++j)
make_red(i, j);
for(int i = 1; i <= n / 2 + 1; ++i)
for(int j = 1; j <= m; ++j)
make_blue(i, j);
}
for(int i = 1; i <= n; ++i)
ans += 2 * row[i] > m;
for(int i = 1; i <= m; ++i)
ans += 2 * col[i] < n;
cout << ans << endl;
for(int i = 1; i <= n; ++i, cout << endl)
for(int j = 1; j <= m; ++j)
cout << (a[i][j] ? '+' : '-');
}
return 0;
}
Compilation message
stones.cpp:53:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
632 KB |
Output is correct |
4 |
Incorrect |
4 ms |
632 KB |
Wrong answer in test 5 29: 31 < 32 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
34 ms |
1784 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
35 ms |
2004 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
632 KB |
Output is correct |
4 |
Incorrect |
4 ms |
632 KB |
Wrong answer in test 5 29: 31 < 32 |