제출 #532511

#제출 시각아이디문제언어결과실행 시간메모리
532511syl123456Red-blue table (IZhO19_stones)C++17
38 / 100
9 ms1868 KiB
#include <bits/stdc++.h> #define all(i) (i).begin(), (i).end() using namespace std; void Debug(bool _split) {} template<typename T1, typename ...T2> void Debug(bool _split, T1 i, T2 ...j) { if (_split) cerr << ", "; cerr << i; Debug(true, j...); } #define debug(args...) cerr << "Line(" << __LINE__ << ") : [" << #args << "] is [", Debug(false, args), cerr << "]" << endl template<typename T1, typename T2> ostream& operator << (ostream& i, pair<T1, T2> j) { return i << '(' << j.first << ", " << j.second << ')'; } typedef long long ll; typedef pair<int, int> pi; const int inf = 0x3f3f3f3f, lg = 20; const ll mod = 1e9 + 7, INF = 0x3f3f3f3f3f3f3f3f; signed main() { ios::sync_with_stdio(0), cin.tie(0); int t; cin >> t; while (t--) { int n, m; cin >> n >> m; vector<string> s(n, string(m, '+')); for (int i = 0; i < n + 2 >> 1; ++i) for (int j = m + 2 >> 1; j < m; ++j) s[i][j] = s[n - 1 - i][m - 1 - j] = '-'; int ans = 0; for (int i = 0; i < n; ++i) if (count(all(s[i]), '+') > count(all(s[i]), '-')) ++ans; for (int j = 0; j < m; ++j) { int tmp = 0; for (int i = 0; i < n; ++i) tmp += s[i][j] == '+' ? -1 : 1; if (tmp > 0) ++ans; } if (ans <= n) { ans = n; for (auto &i : s) i = string(m, '+'); } if (ans <= m) { ans = m; for (auto &i : s) i = string(m, '-'); } if (ans <= n + m - (m + 2 >> 1)) { ans = n + m - (m + 2 >> 1); for (auto &i : s) i = string(m + 2 >> 1, '+') + string(m - (m + 2 >> 1), '-'); } if (ans <= n + m - (n + 2 >> 1)) { ans = n + m - (n + 2 >> 1); for (int i = 0; i < n + 2 >> 1; ++i) s[i] = string(m, '-'); for (int i = n + 2 >> 1; i < n; ++i) s[i] = string(m, '+'); } cout << ans << '\n'; for (string i : s) cout << i << '\n'; } }

컴파일 시 표준 에러 (stderr) 메시지

stones.cpp: In function 'int main()':
stones.cpp:31:31: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   31 |         for (int i = 0; i < n + 2 >> 1; ++i)
      |                             ~~^~~
stones.cpp:32:28: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   32 |             for (int j = m + 2 >> 1; j < m; ++j)
      |                          ~~^~~
stones.cpp:55:31: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   55 |         if (ans <= n + m - (m + 2 >> 1)) {
      |                             ~~^~~
stones.cpp:56:30: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   56 |             ans = n + m - (m + 2 >> 1);
      |                            ~~^~~
stones.cpp:58:30: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   58 |                 i = string(m + 2 >> 1, '+') + string(m - (m + 2 >> 1), '-');
      |                            ~~^~~
stones.cpp:58:61: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   58 |                 i = string(m + 2 >> 1, '+') + string(m - (m + 2 >> 1), '-');
      |                                                           ~~^~~
stones.cpp:60:31: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   60 |         if (ans <= n + m - (n + 2 >> 1)) {
      |                             ~~^~~
stones.cpp:61:30: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   61 |             ans = n + m - (n + 2 >> 1);
      |                            ~~^~~
stones.cpp:62:35: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   62 |             for (int i = 0; i < n + 2 >> 1; ++i)
      |                                 ~~^~~
stones.cpp:64:28: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   64 |             for (int i = n + 2 >> 1; i < n; ++i)
      |                          ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...