# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
340769 | 2020-12-28T10:47:10 Z | David_M | Red-blue table (IZhO19_stones) | C++14 | 2 ms | 492 KB |
#include <bits/stdc++.h> #define ll long long #define pb push_back #define F first #define S second using namespace std; const ll N=1000006; int n, m, q, o, u, e, l, M; string x, y, a[1010]; int main(){ios_base::sync_with_stdio(false), cin.tie(0); cin>>q; while(q--){x="";o=u=0;e=n/2; cin>>n>>m; if(n==1){cout<<m<<endl;while(m--)cout<<'-';cout<<'\n';continue;} if(m==1){cout<<n<<endl;while(n--)cout<<"+\n";continue;} if(n==2){cout<<m<<endl;M=m;while(m--)cout<<'-';cout<<'\n';m=M;while(m--)cout<<'-';cout<<'\n';continue;} if(m==2){cout<<n<<endl;while(n--)cout<<"++\n";continue;} if(n==3){cout<<m+1<<endl;M=m;while(m--)cout<<'-';cout<<'\n';m=M;while(m--)cout<<'-';cout<<'\n';m=M;while(m--)cout<<'+';cout<<'\n';continue;} if(m==3){cout<<n+1<<endl;while(n--)cout<<"++-\n";continue;} if(n==4){cout<<m+1<<endl;M=m;while(m--)cout<<'-';cout<<'\n';m=M;while(m--)cout<<'-';cout<<'\n';m=M;while(m--)cout<<'-';cout<<'\n';m=M;while(m--)cout<<'+';cout<<'\n';continue;} if(m==4){cout<<n+1<<endl;while(n--)cout<<"+++-\n";continue;} if(n%2==1&&m%2==1){ if(n==1){cout<<m<<endl;while(m--)cout<<'-';cout<<'\n';continue;} if(m==1){cout<<n<<endl;while(n--)cout<<"+\n";continue;} cout<<n+m-2<<'\n'; for (int i=1; i<=m/2; i++)x+='-'; for (int i=1; i<=m/2+1; i++)x+='+'; for (int i=1; i<=n/2; i++)cout<<x<<'\n'; for (int i=0; i<m-1; i++)x[i]='-'; x[m-1]='+'; cout<<x<<'\n'; x=""; for (int i=1; i<=m/2; i++)x+='+'; for (int i=1; i<=m/2; i++)x+='-'; x+='+'; for (int i=1; i<=n/2; i++)cout<<x<<'\n'; } if(n%2==0&&m%2==0)if(n<m)n--,o=1; else m--,u=1; if(n%2==1){ for(int i=0; i<n; i++)for(int j=0; j<m; j++)a[i][j]='-'; if(m+4-2*n>=0)l=n-2; else l=n-3; for (int i=0; i<m; i++)for (int j=i; j<i+e; j++)a[min(j%l, n-1)][i]='+'; }else{ for(int i=0; i<n; i++)for(int j=0; j<m; j++)a[i][j]='+'; if(n+4-2*m>=0)l=m-2; else l=m-3; for (int i=0; i<n; i++)for (int j=i; j<i+e; j++)a[i][min(j%l, m-1)]='-'; } cout<<n*(m%2)+m*(n%2)+l<<endl; if(o==1)for (int i=0; i<m; i++)a[n]+='-'; if(u==1)for (int i=0; i<n; i++)a[i]+='+'; for(int i=0; i<n; i++){for(int j=0; j<m; j++)cout<<a[i][j];cout<<'\n';} } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | Runtime error | 1 ms | 492 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 492 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 492 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | 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 | Runtime error | 1 ms | 492 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |