# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168734 | 2019-12-15T15:42:05 Z | Atashka01 | Red-blue table (IZhO19_stones) | C++11 | 65 ms | 1912 KB |
//Euzubillahimines-seytanir-rajim Bismillahir-rahmanir-rahym /* ID: TASK: LANG: C++ */ #include <iostream> #include <vector> #include <map> #include <stack> #include <string> #include <algorithm> #include <cmath> #include <queue> #define pb push_back #define ll long long #define ff first #define ss second #define mp make_pair #define PII pair<int,int> #define inf 1000000001 using namespace std; unsigned int a[1001][1001], ans; void f(unsigned int n,unsigned int m){ vector<pair<int,int>> v; unsigned int k = n*m - ( m*(n/2+1) ); k /= (m/2+1); ans = m + k; for(int i=1;i<=k;i++) for(int j=1;j<=m;j++) a[i][j] = 0; for(int i=1;i<=k;i++) v.push_back( {0,i} ); for(int i=1;i<=m;i++){ int l = k/2 + 1; int t = m/2 + 1; sort(v.begin(),v.end()); for(int j=0;j<v.size();j++){ if( l == 0) break; if( v[j].ff < t ){ a[v[j].ss][i] = 1; v[j].ff++; l--; } } } } unsigned int t; int main(){ cin>>t; while(t--){ unsigned int n, m; cin>>n>>m; if( n!= m ){ f( min(n,m) , max(n,m) ); cout<<ans<<"\n"; if( n > m ){ for(int i=n;i>=1;i--){ for(int j=1;j<=m;j++) if( a[j][i] == 1 ) cout<<"-"; else cout<<"+"; cout<<"\n"; } } else{ for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++) if(a[i][j] == 1) cout<<"+"; else cout<<"-"; cout<<"\n"; } } } else{ f(n,m); cout<<ans<<"\n"; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++) if(a[i][j] == 1) cout<<"+"; else cout<<"-"; cout<<"\n"; } } } } /* _________oBBBBB8o oBBBBBBB8 _____o8BBBBBBBBBBB BBBBBBBBB8 o88o ___o8BBBBBB**8BBBB BBBBBBBBBB oBBBBBBBo __oBBBBBBB* *** BBBBBBBBBB BBBBBBBBBBo _8BBBBBBBBBBooooo *BBBBBBB8 *BB* 8BBBBBBo _8BBBBBBBBBBBBBBBB8ooBBBBBBB8 8BBBBBBB8 __*BBBBBBBBBBBBBBBBBBBBBBBBBB8 o88BB88BBBBBBBBBBBB ____*BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB8 ______**8BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB* ___________*BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB8* ____________*BBBBBBBBBBBBBBBBBBBBBBBB8888** _____________BBBBBBBBBBBBBBBBBBBBBBB* _____________*BBBBBBBBBBBBBBBBBBBBB* ______________*BBBBBBBBBBBBBBBBBB8 _______________*BBBBBBBBBBBBBBBB* ________________8BBBBBBBBBBBBBBB8 _________________8BBBBBBBBBBBBBBBo __________________BBBBBBBBBBBBBBB8 __________________BBBBBBBBBBBBBBBB __________________8BBBBBBBBBBBBBBB8 __________________*BBBBBBBBBBBBBBBB __________________8BBBBBBBBBBBBBBBB8 _________________oBBBBBBBBBBBBBBBBBB ________________oBBBBBBBBBBBBBBBBBBB ________________BBBBBBBBBBBBBBBBBBBB _______________8BBBBBBBBBBBBBBBBBBB8 ______________oBBBBBBBBB88BBBBBBBBB8 ______________8BBBBBBBBB*8BBBBBBBBB* ______________BBBBBBBBB* BBBBBBBBB8 ______________BBBBBBBB8 oBBBBBBBBB* ______________8BBBBBBB oBBBBBBBB* ______________BBBBBBB* 8BBBBBBB* _____________8BBBBBB* BBBBBBB* ____________8BBBBBB8 oBBBBBB8 ___________8BBBBBB8 8BBBBBB* __________oBBBBBB8 BBBBBBB8 __________BBBBBBB8 BBBBBBBB* _________oBBBBBBB8 BBBBBBBB _________8BBBBBB8 BBBBBBB* _________BBBBBB* 8BBBBB* ________oBBBB8 BBBBB* ________oBBB8 BBBB* ________BBBB8 8BBBBo _______8BBBB* oBBBBBBo ______8BBBB* *BBBBBBBB8o ______BBBBB* *88BBBo */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | in the table A+B is not equal to 3 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 376 KB | in the table A+B is not equal to 2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | in the table A+B is not equal to 3 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 65 ms | 1868 KB | in the table A+B is not equal to 10 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 58 ms | 1912 KB | in the table A+B is not equal to 36 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | in the table A+B is not equal to 3 |