제출 #674028

#제출 시각아이디문제언어결과실행 시간메모리
674028VaheRed-blue table (IZhO19_stones)C++17
27 / 100
15 ms1364 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; bool fr; int ydonc_qanaky(vector<string>& v) { int ret = 0; int c = 0; for (string& s : v) { for (char& ch : s) c += (ch == (fr ? '-' : '+')); ret += 2 * c > s.size(); c = 0; } for (int j = 0; j < v[0].size(); j++) { for (int i = 0; i < v.size(); i++) c += v[i][j] == (!fr ? '-' : '+'); ret += 2 * c > v.size(); c = 0; } return ret; } void solve() { fr = 0; int h, w; cin >> h >> w; if (h < w) swap(h, w), fr = 1; string a, b; if (fr) { b = string(w / 2 + 1, '-'); a = string(w - w / 2 - 1, '+'); } else { a = string(w / 2 + 1, '+'); b = string(w - w / 2 - 1, '-'); } int hm = h / 2 + 1, wm = a.size(); string s = a + b; vector<string> ans(h, s); for (int i = 0; i < h; i++) { int h_ = i, w_ = i / hm; if (w_ + wm >= w) break; swap(ans[h_][w_], ans[h_][w_ + wm]); } cout << ydonc_qanaky(ans) << endl; if (fr) { for (int j = w - 1; j >= 0; j--) { for (int i = 0; i < h; i++) cout << ans[i][j]; cout << '\n'; } } else for(string & s : ans) cout << s + "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while(t--) solve(); }

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

stones.cpp: In function 'int ydonc_qanaky(std::vector<std::__cxx11::basic_string<char> >&)':
stones.cpp:10:90: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (string& s : v) { for (char& ch : s) c += (ch == (fr ? '-' : '+')); ret += 2 * c > s.size(); c = 0; }
      |                                                                                    ~~~~~~^~~~~~~~~~
stones.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int j = 0; j < v[0].size(); j++)
      |                     ~~^~~~~~~~~~~~~
stones.cpp:14: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]
   14 |         for (int i = 0; i < v.size(); i++) c += v[i][j] == (!fr ? '-' : '+');
      |                         ~~^~~~~~~~~~
stones.cpp:15:22: 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]
   15 |         ret += 2 * c > v.size();
      |                ~~~~~~^~~~~~~~~~
#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...