# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168887 | 2019-12-17T03:16:11 Z | abil | Red-blue table (IZhO19_stones) | C++14 | 124 ms | 4084 KB |
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() //#define int long long using namespace std; const int N = (1e3 + 12); const int mod = (1e9 + 7); const int INF = (0x3f3f3f3f); int a[N][N], b[N]; main() { int test, n, m; scanf("%d", &test); while(test--){ scanf("%d%d", &n, &m); if(n >= m){ int ans = n; int midn = n / 2 + 1, midm = m / 2 + 1; vector<pair<int,int > > vec; for(int i = 1;i <= m; i++){ for(int j = 1;j <= n; j++){ vec.pb({b[j], j}); } sort(all(vec)); if(vec[midm - 1].fr < n - midn){ ans++; for(int j = 0;j < midm; j++){ a[vec[j].sc][i] = 1; b[vec[j].sc]++; } vec.clear(); } else{ break; } } cout << ans << endl; for(int i = 1;i <= n; i++){ for(int j = 1;j <= m; j++){ if(a[i][j]){ printf("-"); } else{ printf("+"); } } cout << endl; } } else{ int ans = m; int midn = n / 2 + 1, midm = m / 2 + 1; vector<pair<int,int > > vec; for(int i = 1;i <= n; i++){ for(int j = 1;j <= m; j++){ vec.pb({b[j], j}); } sort(all(vec)); if(vec[midn - 1].fr < m - midm){ ans++; for(int j = 0;j < midn; j++){ a[i][vec[j].sc] = 1; b[vec[j].sc]++; } vec.clear(); } else{ break; } } cout << ans << endl; for(int i = 1;i <= n; i++){ for(int j = 1;j <= m; j++){ if(a[i][j]){ printf("+"); } else{ printf("-"); } } cout << endl; } } for(int i = 1;i <= n; i++){ for(int j = 1;j <= m; j++){ a[i][j] = 0; } } for(int i = 1;i <= max(n, m); i++){ b[i] = 0; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | in the table A+B is not equal to 4 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 504 KB | in the table A+B is not equal to 48 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | in the table A+B is not equal to 4 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 124 ms | 1860 KB | in the table A+B is not equal to 118 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 98 ms | 1912 KB | Output is correct |
2 | Correct | 75 ms | 4084 KB | Output is correct |
3 | Correct | 68 ms | 3320 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | in the table A+B is not equal to 4 |
2 | Halted | 0 ms | 0 KB | - |