#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")
#pragma GCC optimize("unroll-loops")
#define ll long long
#define ld long double
#define ull unsigned long long
#define ui unsigned int
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define pf push_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define plli pair<long long, int>
#define pdi pair<double, int>
#define pldldi pair<ld, pair<ld, int>>
#define pdd pair<double, double>
#define pid pair<int, double>
#define piii pair<int, pair<int, int>>
#define pllll pair<long long, long long>
#define pllllll pair<ll, pllll>
#define INF 2e9 + 5
#define size(v) v.size()
#define f first
#define s second
#define Pi 3.14159265359
using namespace std;
int Choice1(int n, int m){
int x = 0, best;
while(x <= n){
if(n - x > x){
best = x;
x++;
}else{
break;
}
}
return m + best;
}
int Choice2(int n, int m){
int x = 0, best;
while(x <= m){
if(m - x > x){
best = x;
x++;
}else{
break;
}
}
return n + best;
}
void solve(){
int n, m;
cin >> n >> m;
if(Choice1(n, m) > Choice2(n, m)){ // m > 2 * x
cout << Choice1(n, m) << "\n";
int x = Choice1(n, m) - m;
vector<vector<char>>grid(n + 1, vector<char>(m + 1, '-'));
for(int i = 1; i <= x; i++){
for(int j = 1; j <= m; j++){
grid[i][j] = '+';
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cout << grid[i][j];
}
cout << "\n";
}
}else{// n > 2 * x
cout << Choice2(n, m) << "\n";
int x = Choice2(n, m) - n;
vector<vector<char>>grid(n + 1, vector<char>(m + 1, '+'));
for(int i = 1; i <= x; i++){
for(int j = 1; j <= n; j++){
grid[j][i] = '-';
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cout << grid[i][j];
}
cout << "\n";
}
}
}
int main(){
int t;
// t = 1;
cin >> t;
while(t--){
solve();
}
return 0;
}
Compilation message
stones.cpp: In function 'int Choice1(int, int)':
stones.cpp:42:16: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
42 | return m + best;
| ^~~~
stones.cpp: In function 'int Choice2(int, int)':
stones.cpp:55:16: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
55 | return n + best;
| ^~~~
stones.cpp: In function 'void solve()':
stones.cpp:55:16: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
55 | return n + best;
| ^~~~
stones.cpp:46:16: note: 'best' was declared here
46 | int x = 0, best;
| ^~~~
stones.cpp:81:26: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
81 | for(int i = 1; i <= x; i++){
| ~~^~~~
stones.cpp:55:16: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
55 | return n + best;
| ^~~~
stones.cpp:46:16: note: 'best' was declared here
46 | int x = 0, best;
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Incorrect |
3 ms |
340 KB |
Wrong answer in test 5 29: 31 < 32 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
34 ms |
1304 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
32 ms |
1260 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Incorrect |
3 ms |
340 KB |
Wrong answer in test 5 29: 31 < 32 |
5 |
Halted |
0 ms |
0 KB |
- |