# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168888 | 2019-12-17T03:19:51 Z | abil | Red-blue table (IZhO19_stones) | C++14 | 131 ms | 5368 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 = m / 2 + 1, midm = n / 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 < m - 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 = m / 2 + 1, midm = n / 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 < n - 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 508 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 15 ms | 508 KB | Output is correct |
4 | Correct | 24 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 131 ms | 1792 KB | Output is correct |
2 | Correct | 81 ms | 4216 KB | Output is correct |
3 | Correct | 83 ms | 4984 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 99 ms | 1944 KB | Output is correct |
2 | Correct | 80 ms | 4072 KB | Output is correct |
3 | Correct | 78 ms | 3348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 15 ms | 508 KB | Output is correct |
4 | Correct | 24 ms | 504 KB | Output is correct |
5 | Correct | 131 ms | 1792 KB | Output is correct |
6 | Correct | 81 ms | 4216 KB | Output is correct |
7 | Correct | 83 ms | 4984 KB | Output is correct |
8 | Correct | 99 ms | 1944 KB | Output is correct |
9 | Correct | 80 ms | 4072 KB | Output is correct |
10 | Correct | 78 ms | 3348 KB | Output is correct |
11 | Correct | 56 ms | 732 KB | Output is correct |
12 | Correct | 80 ms | 4316 KB | Output is correct |
13 | Correct | 82 ms | 4728 KB | Output is correct |
14 | Correct | 69 ms | 3964 KB | Output is correct |
15 | Correct | 106 ms | 5368 KB | Output is correct |
16 | Correct | 67 ms | 4344 KB | Output is correct |
17 | Correct | 33 ms | 3320 KB | Output is correct |