Submission #1126747

#TimeUsernameProblemLanguageResultExecution timeMemory
1126747koukirocksRed-blue table (IZhO19_stones)C++20
100 / 100
23 ms2376 KiB
#include<bits/stdc++.h> #define speed ios_base::sync_with_stdio(0);cin.tie(0) using namespace std; template<typename T> using vvector = vector<vector<T>>; void solve() { int n,m; cin>>n>>m; if (min(n,m)<=2) { if (n==min(n,m)) { cout<<m<<"\n"; for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) cout<<"-"; cout<<"\n"; } } else { cout<<n<<"\n"; for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) cout<<"+"; cout<<"\n"; } } } else { bool swp = n>m; if (n>m) swap(n,m); vvector<char> mp(n+1,vector<char>(m+1,'-')); if (m&1) { cout<<(n+m-4+(n&1)+(m&1))<<"\n"; for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) { if (i>n-2+(n&1)) mp[i][j]='-'; else if (j>m-2+(m&1)) mp[i][j]='+'; else mp[i][j]=((i+j)&1?'-':'+'); } } } else { int a=n-2+(n&1); if (2*a>m+2) a-=2; else a--; cout<<a+m<<"\n"; int now=1; for (int i=1;i<=a;i++) { for (int j=1;j<=(m+2)/2;j++) { mp[i][now]='+'; now++; if (now>m) now=1; } } } if (swp) { for (int j=1;j<=m;j++) { for (int i=1;i<=n;i++) { if (mp[i][j]=='-') cout<<'+'; else cout<<"-"; } cout<<"\n"; } } else { for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) { cout<<mp[i][j]; } cout<<"\n"; } } } } int main() { speed; int t; cin>>t; while (t--) { solve(); } return 0; }
#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...