# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
257099 | BThero | Red-blue table (IZhO19_stones) | C++17 | 13 ms | 1920 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = (int)1e3 + 5;
const int INF = (int)1e9;
char s[MAXN][MAXN];
int cnt[MAXN];
int n, m;
pii ans;
void solve() {
scanf("%d %d", &n, &m);
ans = mp(m, 0);
for (int i = 0; i < m; ++i) {
cnt[i] = n;
}
for (int step = 1, ptr = 0, col = m; step <= n; ++step) {
for (int i = 1; i <= m / 2 + 1; ++i) {
if (--cnt[ptr] < n / 2 + 1) {
--col;
}
ptr = (ptr + 1) % m;
}
ans = max(ans, mp(step + col, step));
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
s[i][j] = '-';
}
s[i][m] = '\0';
}
for (int step = 1, ptr = 0; step <= ans.se; ++step) {
for (int i = 1; i <= m / 2 + 1; ++i) {
s[step - 1][ptr] = '+';
ptr = (ptr + 1) % m;
}
}
printf("%d\n", ans.fi);
for (int i = 0; i < n; ++i) {
printf("%s\n", s[i]);
}
}
int main() {
int tt;
scanf("%d", &tt);
while (tt--) {
solve();
}
return 0;
}
Compilation message (stderr)
# | 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... |