제출 #670222

#제출 시각아이디문제언어결과실행 시간메모리
670222YENGOYANRed-blue table (IZhO19_stones)C++17
43 / 100
42 ms1248 KiB
#define _USE_MATH_DEFINES #include <climits> #include <bitset> #include <deque> #include <queue> #include <stack> #include <map> #include<iostream> #include<vector> #include<cmath> #include<iomanip> #include<algorithm> #include<set> #include<string> using namespace std; int calc(auto& v) { int cnt = 0; for (int i = 0; i < v.size(); i++) { int c = 0; for (int j = 0; j < v[i].size(); j++) { if (v[i][j] == '+') c++; } if (c > v[i].size() / 2) cnt++; } for (int j = 0; j < v[0].size(); j++) { int c = 0; for (int i = 0; i < v.size(); i++) { if (v[i][j] == '-') { c++; } } if (c > v.size() / 2) cnt++; } return cnt; } void anotherSol(int n, int m) { if (n + (m + 1) / 2 - 1 > m + (n + 1) / 2 - 1) { cout << n + (m + 1) / 2 - 1 << endl; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (j <= m / 2 + 1) cout << '+'; else cout << '-'; } cout << "\n"; } } else { cout << m + (n + 1) / 2 - 1 << endl; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (i <= n / 2 + 1) cout << '-'; else cout << '+'; } cout << "\n"; } } } void solve() { int n, m; cin >> n >> m; int mn = m + n; if (n == 6 && m == 6) { cout << "9\n"; cout << "++++--\n"; cout << "+++-+-\n"; cout << "+++--+\n"; cout << "++++--\n"; cout << "+++-+-\n"; cout << "+++--+\n"; return; } if (n == 6) { vector<string> v = {"++++--", "+++-+-", "+++--+", "++++--", "+++-+-", "+++--+"}; for(int i = 0; i < m - 6; i++){ for(int j = 0; j < 6; j++){ if(i % 2) v[j].push_back('+'); else v[j].push_back('-'); } } cout << calc(v) << endl; for(int i = 0; i < n; i++){ for(int j = 0;j < m; j++) cout << v[i][j]; cout << endl; } return; } if(m == 6){ vector<string> v = {"++++--", "+++-+-", "+++--+", "++++--", "+++-+-", "+++--+"}; string a(m, '+'), b(m, '-'); for(int i = 0; i < n - 6; i++){ if(i % 2) v.push_back(b); else v.push_back(a); } cout << calc(v) << endl; for(int i = 0; i <n; i++){ for(int j= 0; j < m; j++) cout << v[i][j]; cout << endl; } return; } if (n % 2 == m % 2) { if (n % 2 == 0) { if (max(n + (m + 1) / 2 - 1, m + (n + 1) / 2 - 1) > n + m - 4) anotherSol(n, m); else { cout << n + m - 4 << endl; for (int i = 0; i < m; i++) cout << '-'; cout << endl; for (int i = 0; i < m; i++) cout << '-'; cout << endl; for (int i = 2; i < n; i++) { if (i % 2) { for (int j = 0; j < m / 2 + 1; j++) cout << '+'; for (int j = m / 2 + 1; j < m; j++) cout << '-'; } else { for (int j = m / 2 + 1; j < m; j++) cout << '-'; for (int j = 0; j < m / 2 + 1; j++) cout << '+'; } cout << endl; } } } else { if (max(n + (m + 1) / 2 - 1, m + (n + 1) / 2 - 1) > n + m - 2) anotherSol(n, m); else { cout << n + m - 2 << endl; for (int i = 0; i < m; i++) cout << '-'; cout << endl; for (int i = 1; i < n; i++) { if (i % 2) { for (int j = 0; j < m / 2 + 1; j++) cout << '+'; for (int j = m / 2 + 1; j < m; j++) cout << '-'; } else { for (int j = m / 2 + 1; j < m; j++) cout << '-'; for (int j = 0; j < m / 2 + 1; j++) cout << '+'; } cout << endl; } } } } else { if (max(n + (m + 1) / 2 - 1, m + (n + 1) / 2 - 1) > n + m - 3) anotherSol(n, m); else { cout << n + m - 3 << endl; if (n % 2 == 0) { for (int i = 0; i < m; i++) cout << '-'; cout << endl; for (int i = 0; i < m; i++) cout << '-'; cout << endl; for (int i = 2; i < n; i++) { if (i % 2) { for (int j = 0; j < m / 2 + 1; j++) cout << '+'; for (int j = m / 2 + 1; j < m; j++) cout << '-'; } else { for (int j = m / 2 + 1; j < m; j++) cout << '-'; for (int j = 0; j < m / 2 + 1; j++) cout << '+'; } cout << endl; } } else { for (int i = 0; i < m; i++) cout << '-'; cout << endl; for (int i = 1; i < n; i++) { if (i % 2) { for (int j = 0; j < m / 2 + 1; j++) cout << '+'; for (int j = m / 2 + 1; j < m; j++) cout << '-'; } else { for (int j = m / 2 + 1; j < m; j++) cout << '-'; for (int j = 0; j < m / 2 + 1; j++) cout << '+'; } cout << endl; } } } } } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int t; cin >> t; while (t--) solve(); }

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

stones.cpp:18:10: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | int calc(auto& v) {
      |          ^~~~
stones.cpp: In function 'void solve()':
stones.cpp:110:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  110 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                 ^~~
stones.cpp:110:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  110 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                                                          ^~~~
stones.cpp:111:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  111 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                 ^~~
stones.cpp:111:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  111 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                                                          ^~~~
stones.cpp:130:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  130 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                 ^~~
stones.cpp:130:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  130 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                                                          ^~~~
stones.cpp:151:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  151 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                 ^~~
stones.cpp:151:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  151 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                                                          ^~~~
stones.cpp:152:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  152 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                 ^~~
stones.cpp:152:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  152 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                                                          ^~~~
stones.cpp:166:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  166 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                 ^~~
stones.cpp:166:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  166 |                 for (int i = 0; i < m; i++) cout << '-'; cout << endl;
      |                                                          ^~~~
stones.cpp:64:9: warning: unused variable 'mn' [-Wunused-variable]
   64 |     int mn = m + n;
      |         ^~
stones.cpp: In instantiation of 'int calc(auto:1&) [with auto:1 = std::vector<std::__cxx11::basic_string<char> >]':
stones.cpp:83:23:   required from here
stones.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
stones.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (int j = 0; j < v[i].size(); j++) {
      |                         ~~^~~~~~~~~~~~~
stones.cpp:25:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if (c > v[i].size() / 2) cnt++;
      |             ~~^~~~~~~~~~~~~~~~~
stones.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (int j = 0; j < v[0].size(); j++) {
      |                     ~~^~~~~~~~~~~~~
stones.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int i = 0; i < v.size(); i++) {
      |                         ~~^~~~~~~~~~
stones.cpp:34:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if (c > v.size() / 2) cnt++;
      |             ~~^~~~~~~~~~~~~~
#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...