제출 #344114

#제출 시각아이디문제언어결과실행 시간메모리
344114RakhmandRed-blue table (IZhO19_stones)C++14
100 / 100
110 ms2412 KiB
// // C.cpp // torelax // // Created by Rakhman on 1/5/21. // #include <cstring> #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <queue> #include <cmath> #include <cstdlib> #include <ctime> #include <cassert> #include <iterator> #define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0); #define S second #define F first #define pb push_back #define nl '\n' #define NL cout << '\n'; #define EX exit(0) #define all(s) s.begin(), s.end() #define no_answer {cout << "NO"; exit(0);} #define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k) const long long mxn = 1e6 + 110; const long long mnn = 1e3 + 2; const long long mod = 1e9 + 7; const long long inf = 1e18; const long long OO = 1e9; typedef long long llong; typedef unsigned long long ullong; using namespace std; int n, m; char ch[mnn][mnn]; void solve(){ int mx = 0, rows = -1, cols = -1; bool swapped = false; cin >> n >> m; if(n < m) { swapped = true; swap(n, m); } for(int i = 0; i <= n; i++){ int x = (m - 1) / 2 * (n - i); llong col = x / ((n + 2) / 2); int lol = n - i + col; if(lol > mx){ mx = lol; rows = i; cols = col; } if(col == m){ break; } } cout << mx << nl; for(int i = 1; i <= rows; i++){ for(int j = 1; j <= m; j++){ ch[i][j] = (swapped == true ? '+' : '-'); } cout << nl; } for(int i = 1; i <= n - rows; i++){ for(int j = 1; j <= m; j++){ ch[i][j] = (swapped == true ? '-' : '+'); } } set<pair<int, int> > st; for(int i = m - cols + 1; i <= m; i++){ st.insert({-1 * (n + 2) / 2 - rows, i}); } for(int i = 1; i <= n - rows; i++){ vector<pair<int, int> > v; for(int j = 1; j <= (m - 1) / 2; j++){ if(st.size() == 0) break; pair<int, int> x = *(st.begin()); st.erase(st.begin()); ch[i][x.S] = (swapped == true ? '+' : '-'); v.push_back({x.F, x.S}); } for(int j = 0; j < v.size(); j++){ if(v[j].F + 1 == 0) continue; st.insert({v[j].F + 1, v[j].S}); } } if(swapped == 1){ for(int j = 1; j <= m; j++){ for(int i = 1; i <= n; i++){ cout << ch[i][j]; } cout << nl; } }else{ for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cout << ch[i][j]; } cout << nl; } } } int main(){ int t; cin >> t; while(t--){ solve(); } }

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

stones.cpp: In function 'void solve()':
stones.cpp:102:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  102 |         for(int j = 0; j < v.size(); j++){
      |                        ~~^~~~~~~~~~
#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...