Submission #852400

#TimeUsernameProblemLanguageResultExecution timeMemory
852400emad234Red-blue table (IZhO19_stones)C++17
42 / 100
64 ms1804 KiB
#include <bits/stdc++.h> #define all(v) ((v).begin(),(v).end()) #define S second #define F first #define ll long long const ll mod = 1e9 + 7; const ll mxN = 2e5 + 2; using namespace std; bool a[1001][1001]; signed main() { ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t; cin >> t; while(t--){ int n,m; cin >>n>>m; int col[1001]; for(int i = 0;i < n;i++){ for(int j = 0;j < m;j++){ a[i][j] = 0; col[j] = n; } } pair<int,int> ans = {m,-1}; int prev = ans.F; bool vis[1001] = {}; for(int i = 0;i < n;i++){ priority_queue<pair<int,int>>pq; queue<int>q; for(int j = 0;j < m;j++){ if(col[j] < n / 2 + 1) q.push({j}); else pq.push({col[j],j}); } while(pq.size()){ q.push((pq.top()).S); pq.pop(); } for(int cnt = 1;cnt <= m / 2 + 1;cnt++){ auto id = q.front();q.pop(); if(col[id] == n / 2 + 1){ prev--; } a[i][id] = 1; col[id]--; // cout<<id<<' '; } // cout<<'\n'; prev++; ans = max(ans,{prev,i}); } cout<<ans.F<<'\n'; for(int i = 0;i <= ans.S;i++){ for(int j = 0;j < m;j++){ cout<<(a[i][j] ? '+' : '-'); } cout<<'\n'; } for(int i = ans.S + 1;i < n;i++){ for(int j = 0;j < m;j++){ cout<<'-'; } cout<<'\n'; } } }

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:27:10: warning: unused variable 'vis' [-Wunused-variable]
   27 |     bool vis[1001] = {};
      |          ^~~
#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...