/**
____ ____ ____ __________________ ____ ____ ____
||I || ||c || ||e || || || ||M || ||a || ||n ||
||__|| ||__|| ||__|| ||________________|| ||__|| ||__|| ||__||
|/__\| |/__\| |/__\| |/________________\| |/__\| |/__\| |/__\|
*/
#include <iostream>
#include <chrono>
#include <stack>
#include <vector>
#define endl '\n'
#define maxn 1000005
#define maxlog 20
#define INF 1000000010
#define LINF 1000000000000000005
#define endl '\n'
#define pb(x) push_back(x)
#define X first
#define Y second
#define control cout<<"passed"<<endl;
#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")
#pragma GCC target("avx2")
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
typedef pair <ll, ll> pll;
typedef pair <int, ll> pil;
typedef pair <ll, int> pli;
typedef long double ld;
std::chrono::high_resolution_clock::time_point startT, currT;
constexpr double TIME_MULT = 1;
double timePassed()
{
using namespace std::chrono;
currT = high_resolution_clock::now();
double time = duration_cast<duration<double>>(currT - startT).count();
return time * TIME_MULT;
}
int n, m;
int br;
void read_solve()
{
cin >> n >> m;
vector <vector <char>> v;
bool lamp = false;
if(m > n)
{
swap(n, m);
lamp = true;
}
v.resize(n + 1);
for(int i = 1; i <= n; i++)
v[i].resize(m + 1);
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
v[i][j] = '+';
br = n;
int idx, pom;
idx = 1;
pom = 0;
for(int cc = 0; cc < (m - 1) / 2; cc++)
for(int i = 1; i <= n; i++)
{
//cout << "in" << endl;
v[i][idx] = '-';
pom++;
if(pom == n / 2 + 1)
{
idx++;
pom = 0;
br++;
}
}
cout << br << endl;
if(lamp == false)
{
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m; j++)
cout << v[i][j];
cout << endl;
}
}
else
{
//cout << "in" << endl;
char pl = '+';
char mi = '-';
for(int i = 1; i <= m; i++)
{
for(int j = 1; j <= n; j++)
if(v[j][i] == '+')
cout << '-';
else
cout << '+';
cout << endl;
}
}
}
void combine()
{
int t;
cin >> t;
while(t--)
read_solve();
}
int main()
{
/**#ifdef ONLINE_JUDGE
freopen("input.in", "r", stdin);
freopen("output.out", "w", stdout);
#endif*/
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
///startT = std::chrono::high_resolution_clock::now();
combine();
return 0;
}
Compilation message
stones.cpp: In function 'void read_solve()':
stones.cpp:110:14: warning: unused variable 'pl' [-Wunused-variable]
110 | char pl = '+';
| ^~
stones.cpp:111:14: warning: unused variable 'mi' [-Wunused-variable]
111 | char mi = '-';
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
1372 KB |
Output is correct |
2 |
Correct |
15 ms |
1628 KB |
Output is correct |
3 |
Correct |
17 ms |
1884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
1372 KB |
Output is correct |
2 |
Correct |
14 ms |
1496 KB |
Output is correct |
3 |
Correct |
16 ms |
1256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
18 ms |
1372 KB |
Output is correct |
6 |
Correct |
15 ms |
1628 KB |
Output is correct |
7 |
Correct |
17 ms |
1884 KB |
Output is correct |
8 |
Correct |
18 ms |
1372 KB |
Output is correct |
9 |
Correct |
14 ms |
1496 KB |
Output is correct |
10 |
Correct |
16 ms |
1256 KB |
Output is correct |
11 |
Correct |
5 ms |
604 KB |
Output is correct |
12 |
Correct |
14 ms |
1436 KB |
Output is correct |
13 |
Correct |
20 ms |
1368 KB |
Output is correct |
14 |
Correct |
11 ms |
1016 KB |
Output is correct |
15 |
Correct |
17 ms |
2396 KB |
Output is correct |
16 |
Correct |
13 ms |
1884 KB |
Output is correct |
17 |
Correct |
6 ms |
1116 KB |
Output is correct |