# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
290606 | 2020-09-04T06:55:02 Z | dantoh000 | Red-blue table (IZhO19_stones) | C++14 | 70 ms | 5372 KB |
#include <bits/stdc++.h> using namespace std; int ans[1005][1005]; int rct[1005]; int cct[1005]; int main(){ int tc; scanf("%d",&tc); while (tc--){ int n,m; scanf("%d%d",&n,&m); int flag = 0; if (n < m){ flag = 1; swap(n,m); } for (int i = 0; i <= n; i++) rct[i] = 0; for (int j = 0; j <= m; j++) cct[j] = 0; for (int i = 0; i < n; i++){ for (int j = 0; j < m; j++) ans[i][j] = 0; } int k = 0; for (k = 0; k <= m; k++){ //printf("k columns: %d, but have %d\n",k*(n - (n-1)/2),((m-1)/2) * n); if (k*(n - (n-1)/2) > ((m-1)/2) * n){ k--; break; } } //printf("%d\n", k); for (int i = 0; i < n; i++){ int num = (m-1)/2; for (int T = 0; T < k; T++){ int j = (T+i)%k; if (cct[j] <= n-cct[j] && num){ cct[j]++; num--; rct[i]++; ans[i][j] = 1; } else ans[i][j] = 0; } for (int T = k; T < m; T++) ans[i][T] = 0; } int sum = 0; for (int i = 0; i < n; i++){ if (rct[i] < m-rct[i]) { //printf("row %d : %d / %d\n",i,rct[i],m); sum++; } } for (int i = 0; i < m; i++){ if (cct[i] > n-cct[i]) { //printf("col %d : %d / %d\n",i,cct[i],n); sum++; } } assert(sum == k+n); printf("%d\n",sum); if (flag){ for (int i = 0; i < m; i++){ for (int j = 0; j < n; j++){ printf("%c",ans[j][i]?'+':'-'); } printf("\n"); } } else{ for (int i = 0; i < n; i++){ for (int j = 0; j < m; j++){ printf("%c",ans[i][j]?'-':'+'); } printf("\n"); } } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 4 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 68 ms | 1912 KB | Output is correct |
2 | Correct | 59 ms | 4728 KB | Output is correct |
3 | Correct | 59 ms | 4856 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 67 ms | 1916 KB | Output is correct |
2 | Correct | 57 ms | 3960 KB | Output is correct |
3 | Correct | 54 ms | 3320 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 4 ms | 512 KB | Output is correct |
5 | Correct | 68 ms | 1912 KB | Output is correct |
6 | Correct | 59 ms | 4728 KB | Output is correct |
7 | Correct | 59 ms | 4856 KB | Output is correct |
8 | Correct | 67 ms | 1916 KB | Output is correct |
9 | Correct | 57 ms | 3960 KB | Output is correct |
10 | Correct | 54 ms | 3320 KB | Output is correct |
11 | Correct | 16 ms | 768 KB | Output is correct |
12 | Correct | 55 ms | 4216 KB | Output is correct |
13 | Correct | 66 ms | 4728 KB | Output is correct |
14 | Correct | 44 ms | 3960 KB | Output is correct |
15 | Correct | 70 ms | 5372 KB | Output is correct |
16 | Correct | 49 ms | 4728 KB | Output is correct |
17 | Correct | 23 ms | 3320 KB | Output is correct |