# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
218331 | 2020-04-02T02:07:50 Z | Lawliet | Red-blue table (IZhO19_stones) | C++17 | 52 ms | 2296 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1010; int n, m; int freq[MAXN]; char ans[MAXN][MAXN]; char aux[MAXN][MAXN]; int main() { int t; scanf("%d",&t); for(int k = 0 ; k < t ; k++) { scanf("%d %d",&n,&m); int qtdColumn = m; int optQtdLine = 0; int optQtdColumn = m; int A = m/2 + 1 - m; int B = (n - 1)/2; for(int qtdLines = 0 ; qtdLines <= n ; qtdLines++) { while( qtdLines*( A + qtdColumn ) > qtdColumn*B ) qtdColumn--; if( optQtdLine + optQtdColumn < qtdLines + qtdColumn ) { optQtdLine = qtdLines; optQtdColumn = qtdColumn; } } printf("%d\n",optQtdLine + optQtdColumn); for(int i = 1 ; i <= optQtdLine ; i++) freq[i] = m/2 + 1; int curCnt = 0; int curLine = 1; int curColumn = 1; for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) ans[i][j] = 'x'; while( curColumn <= optQtdColumn && optQtdLine > 0 ) { if( freq[curLine] == 0 ) break; ans[curLine][curColumn] = '+'; curCnt++; freq[ curLine++ ]--; if( curCnt == n - n/2 - 1 ) { curCnt = 0; curColumn++; } if( curLine == optQtdLine + 1 ) curLine = 1; } for(int i = 1 ; i <= optQtdLine ; i++) for(int j = optQtdColumn + 1 ; j <= m ; j++) ans[i][j] = '+'; for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) if( ans[i][j] == 'x' ) ans[i][j] = '-'; for(int i = 1 ; i <= n ; i++, printf("\n")) for(int j = 1 ; j <= m ; j++) printf("%c",ans[i][j]); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 6 ms | 384 KB | Output is correct |
4 | Correct | 7 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 1608 KB | Output is correct |
2 | Correct | 52 ms | 1912 KB | Output is correct |
3 | Correct | 48 ms | 2172 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 1528 KB | Output is correct |
2 | Correct | 45 ms | 1912 KB | Output is correct |
3 | Correct | 40 ms | 1784 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 6 ms | 384 KB | Output is correct |
4 | Correct | 7 ms | 376 KB | Output is correct |
5 | Correct | 50 ms | 1608 KB | Output is correct |
6 | Correct | 52 ms | 1912 KB | Output is correct |
7 | Correct | 48 ms | 2172 KB | Output is correct |
8 | Correct | 48 ms | 1528 KB | Output is correct |
9 | Correct | 45 ms | 1912 KB | Output is correct |
10 | Correct | 40 ms | 1784 KB | Output is correct |
11 | Correct | 17 ms | 616 KB | Output is correct |
12 | Correct | 40 ms | 1920 KB | Output is correct |
13 | Correct | 45 ms | 2040 KB | Output is correct |
14 | Correct | 34 ms | 1784 KB | Output is correct |
15 | Correct | 48 ms | 2296 KB | Output is correct |
16 | Correct | 37 ms | 1912 KB | Output is correct |
17 | Correct | 21 ms | 1536 KB | Output is correct |