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;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
void solve(int green_flecks){
int n, m;
scanf("%d%d", &n, &m);
bool ok = 0;
if(n < m){
swap(n, m);
ok = 1;
}
vector<vector<int>> A(n, vector<int> (m, 1));
int answer = n, cnt = 0, j_ = 0;
for(int ad = 0; ad < (m-1)>>1; ++ad)
for(int i = 0; i < n; ++i){
A[i][j_] = 0, cnt++;
if(cnt == (n>>1)+1)
j_++, answer++, cnt = 0;
}
// wr;
// for(int i = 0; i < n; ++i){
// for(int j = 0; j < m; ++j)
// printf("%d", A[i][j]);
// puts("");
// }
// wr;
// printf("%d %d %d\n", cnt, answer, j_);
// wr;
printf("%d\n", answer);
if(ok){
for(int i = 0; i < n; ++i)
for(int j = 0; j < m; ++j)
A[i][j] ^= 1;
for(int j = 0; j < m; ++j){
for(int i = 0; i < n; ++i)
if(A[i][j])
printf("+");
else
printf("-");
puts("");
}
return;
}
for(int i = 0; i < n; ++i){
for(int j = 0; j < m; ++j)
if(A[i][j])
printf("+");
else
printf("-");
puts("");
}
}
int main(){
int tt;
scanf("%d", &tt);
while(tt--)
solve(tt);
return 0;
}
Compilation message (stderr)
stones.cpp: In function 'void solve(int)':
stones.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
stones.cpp: In function 'int main()':
stones.cpp:68:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
68 | scanf("%d", &tt);
| ~~~~~^~~~~~~~~~~
# | 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... |