제출 #674344

#제출 시각아이디문제언어결과실행 시간메모리
674344VaheRed-blue table (IZhO19_stones)C++17
100 / 100
11 ms3284 KiB
#include <bits/stdc++.h> using namespace std; void print(vector<string>& v) { int cnt = 0, ans = 0; for (string& s : v) { for (char& c : s) cnt += c == '+'; ans += 2 * cnt > v[0].size(); cnt = 0; } for (int j = 0; j < v[0].size(); j++) { for (int i = 0; i < v.size(); i++) cnt += (v[i][j] == '-'); ans += (2 * cnt > v.size()); cnt = 0; } cout << ans << '\n'; for (string& s : v) cout << s + "\n"; } void fufl(vector<string>& v) { int h = v.size(), w = v[0].size(), boy = h / 2 + 1, lenq = w / 2 + 1; int minus = lenq, plus = 0; int cminus = lenq * (h - boy), cplus = 0 * boy; while (minus < w) { for (int i = 0; i < h && minus < w; i++) { v[i][minus] = v[i][minus] == '-' ? '+' : '-'; v[i][plus] = v[i][plus] == '-' ? '+' : '-'; cminus++; minus = cminus / (h - boy); cplus++; plus = cplus / boy; } } } void solver() { int h, w; cin >> h >> w; vector<string> v(h, string(w, '1')); if(h >= w) { int lenq = w / 2 + 1; string _ = string(lenq, '+'); _ += string(w - lenq, '-'); v = vector<string>(h, _); // fufl(v); } else { int lenq = h / 2 + 1; string _ = string(lenq, '-'); _ += string(h - lenq, '+'); vector<string> tlmp(w, _); fufl(tlmp); //frcnel -> 3.1415926535897932384626433832795105... / 2 radians for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) v[j][w - 1 - i] = tlmp[i][j]; } print(v); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int _; cin >> _; while (_--) solver(); }

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

stones.cpp: In function 'void print(std::vector<std::__cxx11::basic_string<char> >&)':
stones.cpp:8:74: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (string& s : v) { for (char& c : s) cnt += c == '+'; ans += 2 * cnt > v[0].size(); cnt = 0; }
      |                                                                  ~~~~~~~~^~~~~~~~~~~~~
stones.cpp:10:20: 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 (int j = 0; j < v[0].size(); j++) { for (int i = 0; i < v.size(); i++) cnt += (v[i][j] == '-'); ans += (2 * cnt > v.size()); cnt = 0; }
      |                  ~~^~~~~~~~~~~~~
stones.cpp:10:60: 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]
   10 |  for (int j = 0; j < v[0].size(); j++) { for (int i = 0; i < v.size(); i++) cnt += (v[i][j] == '-'); ans += (2 * cnt > v.size()); cnt = 0; }
      |                                                          ~~^~~~~~~~~~
stones.cpp:10:118: 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]
   10 |  for (int j = 0; j < v[0].size(); j++) { for (int i = 0; i < v.size(); i++) cnt += (v[i][j] == '-'); ans += (2 * cnt > v.size()); cnt = 0; }
      |                                                                                                              ~~~~~~~~^~~~~~~~~~
#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...