Submission #898064

#TimeUsernameProblemLanguageResultExecution timeMemory
898064LitusianoRed-blue table (IZhO19_stones)C++17
100 / 100
357 ms9072 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define f first #define s second #define endl '\n' signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t; cin>>t; while(t--){ int n,m; cin>>n>>m; int BOT = n/2; int BOT1 = m/2; int REM = n - BOT -1; int REM1 = m-BOT1 - 1; int a = n; a+= n*REM1/(BOT+1); int b = m ; b+= m*REM/(BOT1+1); if(a >= b){ // cerr<<"HERE!"<<endl; int x = a-n; vector<vector<int>> v(n, vector<int>(m,1)); // all red vector<int> need(x,BOT+1); for(int i = 0; i<n; i++){ int hv = REM1; for(int j = 0; j<REM1; j++){ int mn = -INT_MAX; int idx = -1; for(int k = 0; k<need.size(); k++){ if(need[k] > mn) mn = need[k], idx = k; } hv--; need[idx]--; // cerr<<i<<" "<<idx<<endl; v[i][idx] = 0; } } cout<<a<<endl; for(auto x : v){ for(auto y : x){ if(y) cout<<"+"; else cout<<"-"; } cout<<endl; } } else{ // cerr<<"HERE1!"<<endl; int x = b-m; // He activat columnes, ara haig dactivar files. vector<vector<int>> v(n, vector<int>(m,0)); // all red vector<int> need(x,BOT1+1); for(int i = 0; i<m; i++){ int hv = REM; for(int j = 0; j<REM; j++){ int mn = -INT_MAX; int idx = -1; for(int k = 0; k<need.size(); k++){ if(need[k] > mn) mn = need[k], idx = k; } hv--; need[idx]--; v[idx][i] = 1; } } cout<<b<<endl; for(auto x : v){ for(auto y : x){ if(y) cout<<"+"; else cout<<"-"; } cout<<endl; } } } } /* 1 3 7 9 10 10 + 24 9 + 11 7 + 4 1 + 3 */

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:34:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |      for(int k = 0; k<need.size(); k++){
      |                     ~^~~~~~~~~~~~
stones.cpp:64:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |      for(int k = 0; k<need.size(); k++){
      |                     ~^~~~~~~~~~~~
#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...