# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
255886 | karma | Red-blue table (IZhO19_stones) | C++14 | 96 ms | 3084 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define fi first
#define se second
#define mp make_pair
//#define int int64_t
using namespace std;
const int N = int(1e3) + 7;
const int inf = 1e9 + 1;
typedef pair<ll, ll> pii;
int cnt[N], n, m;
void solve() {
cin >> n >> m;
vector<vector<int>> ans(n, vector<int>(m, 0));
priority_queue<pii, vector<pii>, greater<pii>> pq;
/// column -, row +
fill(cnt, cnt + m, 0);
for(int i = 0; i < m; ++i) pq.emplace(0, i);
int res = m, num = 0;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j * 2 <= m; ++j) {
auto top = pq.top(); pq.pop();
++cnt[top.se];
pq.emplace(top.fi + 1, top.se);
}
auto top = pq.top(); pq.pop();
++cnt[top.se];
pq.emplace(top.fi + 1, top.se);
int tmp = 0;
for(int j = 0; j < m; ++j)
if(cnt[j] * 2 < n) ++tmp;
if(tmp + i > res) res = tmp + i, num = i;
}
cout << res << '\n';
fill(cnt, cnt + m, 0);
for(int i = 0; i < m; ++i) pq.emplace(0, i);
for(int i = 0; i < num; ++i) {
for(int j = 1; j * 2 <= m; ++j) {
auto top = pq.top(); pq.pop();
++cnt[top.se];
ans[i][top.se] = 1;
pq.emplace(top.fi + 1, top.se);
}
auto top = pq.top(); pq.pop();
++cnt[top.se];
ans[i][top.se] = 1;
pq.emplace(top.fi + 1, top.se);
}
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j) {
cout << (ans[i][j] == 0? '-': '+');
}
cout << '\n';
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
#define Task "test"
if(fopen(Task".inp", "r")) {
freopen(Task".inp", "r", stdin);
freopen(Task".out", "w", stdout);
}
int T; cin >> T;
while(T --) solve();
}
컴파일 시 표준 에러 (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... |