제출 #1228793

#제출 시각아이디문제언어결과실행 시간메모리
1228793ByeWorldRed-blue table (IZhO19_stones)C++20
0 / 100
26 ms1608 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #define int long long #define ll long long #define se second #define fi first #define pb push_back #define lf (id<<1) #define rg ((id<<1)|1) #define md ((l+r)>>1) using namespace std; typedef pair<int,int> pii; typedef pair<pii,pii> ipii; const int MAXN = 2e5+10; const int SQRT = 450; const int INF = 2e9; const int MOD = 998244353; const int LOG = 20; int sum(int a, int b){ return (a+MOD+b)%MOD; } void chsum(int &a, int b){ a = (a+MOD+b)%MOD; } int mul(int a, int b){ return (a*b)%MOD; } void chmul(int &a, int b){ a = (a*b)%MOD; } void chmn(auto &a, auto b){ a = min(a, b); } void chmx(auto &a, auto b){ a = max(a, b); } int n, m; bool sw; bool ans[1010][1010], b[1010][1010]; // 0 blue col, 1 red row signed main(){ // ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int T; cin>>T; while(T--){ cin>>n>>m; if(n > m) sw = 1, swap(n, m); else sw = 0; if(n<=2){ for(int i=1; i<=m; i++) ans[1][i] = ans[2][i] = 0; } else { for(int i=1; i<=m; i++) ans[i%2+2][i] = 1; } if(sw){ for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) b[j][i] = 1-ans[i][j]; for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) ans[i][j] = b[i][j]; swap(n, m); } int all = 0; for(int i=1; i<=n; i++){ int tot = 0; for(int j=1; j<=m; j++){ if(ans[i][j]) tot++; } if(tot > m/2) all++; } for(int j=1; j<=m; j++){ int tot = 0; for(int i=1; i<=n; i++){ if(ans[i][j]==0) tot++; } if(tot > n/2) all++; } cout << all << '\n'; for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ cout << (ans[i][j] ? '+' : '-'); } cout << '\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...