# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
152925 | 2019-09-10T13:33:32 Z | beso123 | Red-blue table (IZhO19_stones) | C++14 | 96 ms | 2972 KB |
#include <bits/stdc++.h> using namespace std; char a[1001][1001]; char a1[1001][1001]; pair <int,int> check(int n,int m){ int t=0; if(n<=m){ t=m-2; t=t+(n-1); if(n%2==1) t++; for(int k=1;k<=n;k++) for(int i=1;i<=m;i++) a[k][i]='-'; int n1=0,m1=0; if(n%2==0) n1=n/2-1; else n1=n/2; if(m%2==0) m1=m/2+1; else m1=m/2+1; for(int k=1;k<n;k+=1){ if(k%2==1){ int f=0; for(int i=1;i<=m;i+=2) if(i<=m){ a[k][i]='+'; f++; } if(f<m1) a[k][2]='+'; } else{ int f=0; for(int i=2;i<=m;i+=2) if(i<=m){ a[k][i]='+'; f++; } if(f<m1) a[k][1]='+'; } } } else{ t=n-2; t=t+(m-1); if(m%2==1) t++; for(int k=1;k<=n;k++) for(int i=1;i<=m;i++) a[k][i]='+'; int n1=0,m1=0; if(n%2==0) n1=n/2+1; else n1=n/2+1; if(m%2==0) m1=m/2-1; else m1=m/2; for(int k=1;k<m;k++){ int f=0; if(k%2==1){ for(int i=1;i<=n;i+=2) if(i<=n){ f++; a[i][k]='-'; } if(f<n1) a[1][k]='-'; } else{ for(int i=2;i<=n;i+=2) if(i<=n){ f++; a[i][k]='-'; } if(f<n1) a[1][k]='-'; } } } int t1=0; if(n<=m){ t1=m; for(int k=1;k<=n;k++) for(int i=1;i<=m;i++) a1[k][i]='-'; int n1=0,m1=0; if(n%2==0) n1=n/2-1; else n1=n/2; if(m%2==0) m1=m/2+1; else m1=m/2+1; t1+=n1; int t=0; if(n%2==0){ if(n/2!=n1) for(int k=1;k<=n1;k++) for(int i=1;i<=m1;i++) a1[k][i]='+'; } else{ if(m%2==0){ if(m1*2!=m) for(int k=1;k<=n1;k++) for(int i=1;i<=m1;i++) a1[k][i]='+'; } else{ for(int k=1;k<=n1;k++) for(int i=1;i<=m1;i++) a1[k][i]='+'; } } } else{ t1=n; for(int k=1;k<=n;k++) for(int i=1;i<=m;i++) a1[k][i]='+'; int n1=0,m1=0; if(n%2==0) n1=n/2+1; else n1=n/2+1; if(m%2==0) m1=m/2-1; else m1=m/2; t1+=m1; int t=0; if(n%2==0){ if(n/2!=n1) for(int k=1;k<=n1;k++) for(int i=1;i<=m1;i++) a1[k][i]='-'; } else{ if(m%2==0){ int t=0; if(n<=m){ t=m; for(int k=1;k<=n;k++) for(int i=1;i<=m;i++) a[k][i]='-'; int n1=0,m1=0; if(n%2==0) n1=n/2-1; else n1=n/2; if(m%2==0) m1=m/2+1; else m1=m/2+1; t+=n1; int t=0; if(n%2==0){ if(n/2!=n1) for(int k=1;k<=n1;k++) for(int i=1;i<=m1;i++) a[k][i]='+'; } else{ if(m%2==0){ if(m1*2!=m) for(int k=1;k<=n1;k++) for(int i=1;i<=m1;i++) a[k][i]='+'; } else{ for(int k=1;k<=n1;k++) for(int i=1;i<=m1;i++) a[k][i]='+'; } } } else{ t=n; for(int k=1;k<=n;k++) for(int i=1;i<=m;i++) a[k][i]='+'; int n1=0,m1=0; if(n%2==0) n1=n/2+1; else n1=n/2+1; if(m%2==0) m1=m/2-1; else m1=m/2; t+=m1; int t=0; if(n%2==0){ if(n/2!=n1) for(int k=1;k<=n1;k++) for(int i=1;i<=m1;i++) a[k][i]='-'; } else{ if(m%2==0){ if(m1*2!=m) for(int k=1;k<=n1;k++) for(int i=1;i<=m1;i++) a[k][i]='-'; } else{ for(int k=1;k<=n1;k++) for(int i=1;i<=m1;i++) a[k][i]='-'; } } } if(m1*2!=m) for(int k=1;k<=n1;k++) for(int i=1;i<=m1;i++) a1[k][i]='-'; } else{ for(int k=1;k<=n1;k++) for(int i=1;i<=m1;i++) a1[k][i]='-'; } } } if(t>t1) return {t,1}; else return {t1,2}; } int main(){ int T; cin>>T; int r=0; while(r<T){ int n,m; cin>>n>>m; r++; pair <int,int> ans=check(n,m); cout<<ans.first<<endl; if(ans.second==1) for(int k=1;k<=n;k++){ for(int i=1;i<=m;i++) cout<<a[k][i]; cout<<endl; } else for(int k=1;k<=n;k++){ for(int i=1;i<=m;i++) cout<<a1[k][i]; cout<<endl; } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 15 ms | 376 KB | Output is correct |
4 | Incorrect | 25 ms | 504 KB | in the table A+B is not equal to 41 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 96 ms | 1528 KB | Output is correct |
2 | Correct | 46 ms | 2636 KB | Output is correct |
3 | Correct | 45 ms | 2972 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 77 ms | 1528 KB | in the table A+B is not equal to 45 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 15 ms | 376 KB | Output is correct |
4 | Incorrect | 25 ms | 504 KB | in the table A+B is not equal to 41 |