# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
395736 | 2021-04-28T20:08:16 Z | peuch | Red-blue table (IZhO19_stones) | C++17 | 129 ms | 2244 KB |
#include<bits/stdc++.h> using namespace std; const int MAXN = 1010; int t; int n, m; int k, l; int ans; int in[MAXN]; char grid[MAXN][MAXN]; bool inv; set<pair<int, int> > s; int main(){ scanf("%d", &t); while(t--){ s.clear(); scanf("%d %d", &n, &m); if(n < m) swap(n, m), inv = true; else inv = false; k = n / 2 + 1; l = m / 2 + 1; ans = n; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++) grid[i][j] = (inv) ? '-' : '+'; s.insert(make_pair(-m, i)); in[i] = m; } for(int j = 1; j <= m; j++){ vector<int> ids; bool flag = false; for(int _ = 0; _ < k; _++){ ids.push_back(s.begin()->second); if(s.begin()->first == -l) flag = true; s.erase(s.begin()); } if(flag) break; ans++; for(int i = 0; i < ids.size(); i++){ int cur = ids[i]; in[cur]--; s.insert(make_pair(-in[cur], cur)); grid[cur][j] = (inv) ? '+' : '-'; } } printf("%d\n", ans); if(inv) swap(n, m); for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ printf("%c", (inv) ? grid[j][i] : grid[i][j]); } printf("\n"); } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 3 ms | 332 KB | Output is correct |
4 | Correct | 9 ms | 304 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 129 ms | 1356 KB | Output is correct |
2 | Correct | 115 ms | 2100 KB | Output is correct |
3 | Correct | 108 ms | 2032 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 111 ms | 1372 KB | Output is correct |
2 | Correct | 100 ms | 1860 KB | Output is correct |
3 | Correct | 97 ms | 1636 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 3 ms | 332 KB | Output is correct |
4 | Correct | 9 ms | 304 KB | Output is correct |
5 | Correct | 129 ms | 1356 KB | Output is correct |
6 | Correct | 115 ms | 2100 KB | Output is correct |
7 | Correct | 108 ms | 2032 KB | Output is correct |
8 | Correct | 111 ms | 1372 KB | Output is correct |
9 | Correct | 100 ms | 1860 KB | Output is correct |
10 | Correct | 97 ms | 1636 KB | Output is correct |
11 | Correct | 26 ms | 588 KB | Output is correct |
12 | Correct | 98 ms | 1936 KB | Output is correct |
13 | Correct | 103 ms | 2060 KB | Output is correct |
14 | Correct | 82 ms | 1672 KB | Output is correct |
15 | Correct | 129 ms | 2244 KB | Output is correct |
16 | Correct | 94 ms | 1880 KB | Output is correct |
17 | Correct | 43 ms | 1256 KB | Output is correct |