# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
371162 | 2021-02-26T02:21:24 Z | daniel920712 | Red-blue table (IZhO19_stones) | C++14 | 219 ms | 5356 KB |
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <assert.h> using namespace std; int all[1005][1005]; int con[1005]; int main() { int T,N,M,ans=0,i,j,k,ok=1,t; scanf("%d",&T); while(T--) { ans=0,ok=0; scanf("%d %d",&N,&M); if(N>M) { ok=1; swap(N,M); } if(N<=M) { ans=M; for(i=0;i<=N/2;i++) { con[i]=0; for(j=0;j<M;j++) all[i][j]=0; } for(i=N/2+1;i<N;i++) { con[i]=M; for(j=0;j<M;j++) all[i][j]=1; } for(i=0;i<=N/2;i++) { for(j=0;j<M;j++) { if(con[i]<=(M-con[i])) { for(k=N/2+1;k<N;k++) { if(all[k][j]==1&&all[i][j]==0) { if(con[k]-1>(M-con[k]+1)) { con[k]--; con[i]++; swap(all[i][j],all[k][j]); } } } } } } ans=M; for(i=0;i<N;i++) { t=0; for(j=0;j<M;j++) { //printf("%d ",all[i][j]); if(all[i][j]==1) t++; } //printf("\n"); assert(t==con[i]); if(con[i]>(M-con[i])) ans++; } for(i=0;i<M;i++) { t=0; for(j=0;j<N;j++) { if(all[j][i]==0) t++; } //printf("%d %d\n",i,t); //assert(t>(N-t)); } } if(ok==0) { printf("%d\n",ans); for(i=0;i<N;i++) { for(j=0;j<M;j++) { if(all[i][j]==0) printf("-"); else printf("+"); } printf("\n"); } } else { printf("%d\n",ans); for(i=0;i<M;i++) { for(j=0;j<N;j++) { if(all[j][i]==1) printf("-"); else printf("+"); } printf("\n"); } } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 2 ms | 364 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 64 ms | 1736 KB | Output is correct |
2 | Correct | 153 ms | 4224 KB | Output is correct |
3 | Correct | 143 ms | 4204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 69 ms | 1900 KB | Output is correct |
2 | Correct | 127 ms | 3948 KB | Output is correct |
3 | Correct | 104 ms | 3436 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 2 ms | 364 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 64 ms | 1736 KB | Output is correct |
6 | Correct | 153 ms | 4224 KB | Output is correct |
7 | Correct | 143 ms | 4204 KB | Output is correct |
8 | Correct | 69 ms | 1900 KB | Output is correct |
9 | Correct | 127 ms | 3948 KB | Output is correct |
10 | Correct | 104 ms | 3436 KB | Output is correct |
11 | Correct | 14 ms | 748 KB | Output is correct |
12 | Correct | 95 ms | 3284 KB | Output is correct |
13 | Correct | 82 ms | 3180 KB | Output is correct |
14 | Correct | 57 ms | 2412 KB | Output is correct |
15 | Correct | 219 ms | 5356 KB | Output is correct |
16 | Correct | 137 ms | 4204 KB | Output is correct |
17 | Correct | 42 ms | 2540 KB | Output is correct |