제출 #170865

#제출 시각아이디문제언어결과실행 시간메모리
170865TricksterRed-blue table (IZhO19_stones)C++14
15 / 100
85 ms1872 KiB
#include <algorithm> #include <iostream> #include <stdio.h> #include <vector> #include <queue> #include <cmath> #include <set> #include <map> #define N 1010 #define ff first #define ss second #define ll long long #define pb push_back #define mod 1000000007 #define pii pair <int, int> using namespace std; int t; int n, m; char v[N][N]; int main() { cin >> t; while(t--) { cin >> n >> m; for(int i = 1; i <= n; i++) for(int h = 1; h <= m; h++) v[i][h] = (n > m ? '+' : '-'); if(n >= m) { priority_queue <pii, vector <pii>, greater<pii>> Q; for(int i = 1; i <= m; i++) Q.push({0, i}); int li = m/2 + 1; int sz = n/2 - (n%2 == 0 ? 1 : 0); for(int i = 1; i <= n; i++) { vector <pii> A; for(int h = 1; h <= li; h++) { pii x = Q.top(); Q.pop(); if(x.ff == sz) break; A.pb(x); if(Q.empty()) break; } if(A.size() < li) break; for(auto h: A) v[i][h.ss] = '+', Q.push({h.ff+1, h.ss}); } } else { priority_queue <pii, vector <pii>, greater<pii>> Q; for(int i = 1; i <= n; i++) Q.push({0, i}); int li = n/2 + 1; int sz = m/2 - (m%2 == 0 ? 1 : 0); for(int i = 1; i <= m; i++) { vector <pii> A; for(int h = 1; h <= li; h++) { pii x = Q.top(); Q.pop(); if(x.ff == sz) break; A.pb(x); if(Q.empty()) break; } if(A.size() < li) break; for(auto h: A) v[h.ss][i] = '-', Q.push({h.ff+1, h.ss}); } } int ans = 0; for(int i = 1; i <= n; i++) { int sum = 0; for(int h = 1; h <= m; h++) sum += (v[i][h] == '+' ? 1 : 0); if(sum > m/2) ans++; } for(int i = 1; i <= m; i++) { int sum = 0; for(int h = 1; h <= n; h++) sum += (v[h][i] == '-' ? 1 : 0); if(sum > n/2) ans++; } cout << ans << "\n"; for(int i = 1; i <= n; i++) { for(int h = 1; h <= m; h++) cout << v[i][h]; cout << "\n"; } } }

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

stones.cpp: In function 'int main()':
stones.cpp:56:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(A.size() < li) break;
        ~~~~~~~~~^~~~
stones.cpp:82:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(A.size() < li) break;
        ~~~~~~~~~^~~~
#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...