#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool fr;
int ydonc_qanaky(vector<string>& v)
{
int ret = 0;
int c = 0;
for (string& s : v) { for (char& ch : s) c += (ch == (fr ? '-' : '+')); ret += 2 * c > s.size(); c = 0; }
for (int j = 0; j < v[0].size(); j++)
{
for (int i = 0; i < v.size(); i++) c += v[i][j] == (!fr ? '-' : '+');
ret += 2 * c > v.size();
c = 0;
}
return ret;
}
void solve() {
fr = 0;
int h, w; cin >> h >> w; if (h < w) swap(h, w), fr = 1;
string a, b;
if (fr) { b = string(w / 2 + 1, '-'); a = string(w - w / 2 - 1, '+'); }
else { a = string(w / 2 + 1, '+'); b = string(w - w / 2 - 1, '-'); }
int hm = h / 2 + 1, wm = a.size();
string s = a + b;
vector<string> ans(h, s);
for (int i = 0; i < h; i++)
{
int h_ = i, w_ = i / hm;
if (w_ + wm >= w) break;
swap(ans[h_][w_], ans[h_][w_ + wm]);
}
cout << ydonc_qanaky(ans) << endl;
if (fr)
{
for (int j = w - 1; j >= 0; j--)
{
for (int i = 0; i < h; i++) cout << ans[i][j];
cout << '\n';
}
}
else for(string & s : ans) cout << s + "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t; cin >> t; while(t--)
solve();
}
Compilation message
stones.cpp: In function 'int ydonc_qanaky(std::vector<std::__cxx11::basic_string<char> >&)':
stones.cpp:10:90: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | for (string& s : v) { for (char& ch : s) c += (ch == (fr ? '-' : '+')); ret += 2 * c > s.size(); c = 0; }
| ~~~~~~^~~~~~~~~~
stones.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | for (int j = 0; j < v[0].size(); j++)
| ~~^~~~~~~~~~~~~
stones.cpp:14:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for (int i = 0; i < v.size(); i++) c += v[i][j] == (!fr ? '-' : '+');
| ~~^~~~~~~~~~
stones.cpp:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | ret += 2 * c > v.size();
| ~~~~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Incorrect |
2 ms |
340 KB |
Wrong answer in test 5 29: 31 < 32 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
1332 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
1364 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 |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Incorrect |
2 ms |
340 KB |
Wrong answer in test 5 29: 31 < 32 |
5 |
Halted |
0 ms |
0 KB |
- |