이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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';
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |