이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn=1e3+5;
int tt,ans,ps,need;
int n,m,tr,a[maxn][maxn];
int cnt[maxn],num[maxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin >> tt;
while(tt--){
cin >> n >> m;
tr = 0;
if(n % 2 == 0) swap(n,m),tr=1;
for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++) a[i][j]=1;
if(min(n,m) <= 2){
ans = max(n,m);
for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++){
if(n > m) a[i][j]=1;
else a[i][j]=0;
}
}
else{
ans = n - 2,ps = m/2+1,need = n/2+1;
for(int i = n - 1;i <= n;i++) for(int j = 1;j <= m;j++) a[i][j]=0;
for(int i = 1;i <= m;i++) cnt[i] = 2;
for(int i = 1;i <= n-2;i++) num[i] = m;
for(int i = 1;i <= m;i++){
for(int j = 1;j <= n-2;j++){
if(cnt[i]==need){break;}
if(num[j] > ps){
a[j][i] = 0;
num[j]--,cnt[i]++;
}
}
if(cnt[i]==need) ans++;
}
}
cout<<ans<<'\n';
if(tr) swap(n,m);
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
char nw = '+';
if((tr and a[j][i]==1) or (tr==0 and a[i][j]==0)) nw = '-';
cout<<nw;
}
cout<<'\n';
}
}
}
# | 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... |