# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
395741 | andremfq | Red-blue table (IZhO19_stones) | C++17 | 129 ms | 2232 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
gulosinho da Carol. vai passando nas colunas e deixando elas boas, e pra isso mantem a qtd de - de cada linha
*/
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
int t;
int n, m;
int k, l;
int ans;
int in[MAXN];
char grid[MAXN][MAXN];
bool inv;
set<pair<int, int> > s;
int main(){
scanf("%d", &t);
while(t--){
s.clear();
scanf("%d %d", &n, &m);
if(n < m) swap(n, m), inv = true;
else inv = false;
k = n / 2 + 1;
l = m / 2 + 1;
ans = n;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++)
grid[i][j] = (inv) ? '-' : '+';
s.insert(make_pair(-m, i));
in[i] = m;
}
for(int j = 1; j <= m; j++){
vector<int> ids;
bool flag = false;
for(int _ = 0; _ < k; _++){
ids.push_back(s.begin()->second);
if(s.begin()->first == -l) flag = true;
s.erase(s.begin());
}
if(flag) break;
ans++;
for(int i = 0; i < ids.size(); i++){
int cur = ids[i];
in[cur]--;
s.insert(make_pair(-in[cur], cur));
grid[cur][j] = (inv) ? '+' : '-';
}
}
printf("%d\n", ans);
if(inv) swap(n, m);
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
printf("%c", (inv) ? grid[j][i] : grid[i][j]);
}
printf("\n");
}
}
}
컴파일 시 표준 에러 (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... |