# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168739 | 2019-12-15T17:22:58 Z | RafaelSus | Red-blue table (IZhO19_stones) | C++14 | 68 ms | 2464 KB |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t-- > 0){ int n, m; cin >> n >> m; ///////////////////OK if (n == 1){ cout << m << '\n'; for (int i = 0; i < m; i++){ cout << "-"; } cout << '\n'; continue; }else if (m == 1){ cout << n << '\n'; for (int i = 0; i < n; i++){ cout << "+\n"; } continue; }//////////////////OK if (n >= m){ vector <vector <char>> g(n, vector <char>(m, '-')); for (int i = 0; i < n; i++){ g[i][0] = '+'; g[i][m - 1] = '+'; } int x = (m - 2) / 2; vector <int> vec(m - 2, 0); int mx = 0; for (int i = 0; i < x; i++){ vec[i * 2] = 1; mx = i * 2; } int low = 0, high = mx; for (int i = 0; i < n; i++){ for (int j = 1; j < m - 1; j++){ if (vec[j - 1] == 1)g[i][j] = '+'; else g[i][j] = '-'; } vector <int> used(m); //for (auto x : vec) cout << x << ' '; //cout << '\n'; for (int j = 0; j <= m - 2; j++){ if (vec[j] == 1 && !used[j]){ vec[j] = 0; if (j + 1 < m - 2){ vec[j + 1] = 1; used[j + 1] = 1; }else{ vec[0] = 1; used[0] = 1; } } } } ////////////////////// //CHECK/////////////// ////////////////////// int answ = 0; for (int i = 0; i < n; i++){ int h = 0; for (int j = 0; j < m; j++){ if (g[i][j] == '+')h++; } if (h > (m - h))answ++; } for (int i = 0; i < m; i++){ int h = 0; for (int j = 0; j < n; j++){ if (g[j][i] == '-')h++; } if (h > (n - h))answ++; } cout << answ << '\n'; for (int i = 0; i < n; i++){ for (int j = 0; j < m; j++){ cout << g[i][j] << ' '; } cout << '\n'; } } else{ vector <vector <char>> g(n, vector <char>(m, '-')); int x = (n - 2) / 2; vector <int> vec(n - 2, 0); int mx = 0; for (int i = 0; i < x; i++){ vec[i * 2] = 1; mx = i * 2; } int low = 0, high = mx; for (int i = 0; i < m; i++){ for (int j = 1; j < n - 1; j++){ if (vec[j - 1] == 1)g[j][i] = '-'; else g[j][i] = '+'; } vector <int> used(n); //for (auto x : vec) cout << x << ' '; //cout << '\n'; for (int j = 0; j <= n - 2; j++){ if (vec[j] == 1 && !used[j]){ vec[j] = 0; if (j + 1 < n - 2){ vec[j + 1] = 1; used[j + 1] = 1; }else{ vec[0] = 1; used[0] = 1; } } } } ////////////////////// //CHECK/////////////// ////////////////////// int answ = 0; for (int i = 0; i < n; i++){ int h = 0; for (int j = 0; j < m; j++){ if (g[i][j] == '+')h++; } if (h > (m - h))answ++; } for (int i = 0; i < m; i++){ int h = 0; for (int j = 0; j < n; j++){ if (g[j][i] == '-')h++; } if (h > (n - h))answ++; } cout << answ << '\n'; for (int i = 0; i < n; i++){ for (int j = 0; j < m; j++){ cout << g[i][j] << ' '; } cout << '\n'; } } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Wrong answer |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Wrong answer |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 68 ms | 2464 KB | Wrong answer |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 47 ms | 2008 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Wrong answer |
2 | Halted | 0 ms | 0 KB | - |