#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
stones.cpp: In function 'int main()':
stones.cpp:27:10: warning: unused variable 'vis' [-Wunused-variable]
27 | bool vis[1001] = {};
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
4 |
Incorrect |
3 ms |
348 KB |
Wrong answer in test 37 5: 39 < 40 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
1488 KB |
Wrong answer in test 97 21: 112 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
1596 KB |
Output is correct |
2 |
Correct |
64 ms |
1804 KB |
Output is correct |
3 |
Correct |
59 ms |
1620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
4 |
Incorrect |
3 ms |
348 KB |
Wrong answer in test 37 5: 39 < 40 |
5 |
Halted |
0 ms |
0 KB |
- |