# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
236540 | kshitij_sodani | Red-blue table (IZhO19_stones) | C++17 | 115 ms | 6140 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
int n,m,t;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>t;
while(t--){
cin>>n>>m;
int k=(n+2)/2;
int l=(m+2)/2;
int ma=-1;
pair<int,int> aa={-1,-1};
int bb=m;
for(int i=0;i<=n;i++){
for(int j=0;j<=m;j++){
if(i*l+j*k<=n*m){
int le2=m-j;
int st=1;
if(l>le2){
if((l-le2)*i>(n-k)*(j)){
st=0;
}
}
if(st){
if(i+j>ma){
ma=i+j;
aa={i,j};
}
}
}
}
/*if(i+bb>=ma){
ma=i+bb;
aa={i,bb};
}*/
}
if(aa.b<0){
while(true){
continue;
}
}
int it[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
it[i][j]=0;
}
}
int le=m-aa.b;
/*if(ma==34){
return 0;
}*/
//cout<<ma<<endl;
deque<int> freq[1001];
int ind=0;
for(int i=0;i<1001;i++){
freq[i].clear();
}
for(int i=le;i<m;i++){
freq[0].pb(i);
}
//(m-le)
//cout<<aa.a<<","<<aa.b<<endl;
int vis[1001];
for(int i=0;i<1001;i++){
vis[i]=0;
}
int cot[1001];
for(int i=0;i<1001;i++){
cot[i]=0;
}
for(int i=0;i<aa.a;i++){
vector<int> kk;
for(int j=0;j<l;j++){
if(j<le){
it[i][j]=1;
continue;
}
if(freq[ind].size()==0){
ind+=1;
}
/* if(ind>=(m-1)/2){
while(true){
continue;
}
}*/
it[i][freq[ind].back()]=1;
// cout<<i<<":"<<freq[ind].back()<<endl;
int xx=freq[ind].back();
kk.pb(xx);
vis[xx]=1;
cot[xx]+=1;
/* if(ind>=(n-1)/2){
while(true){
continue;
}
}*/
freq[ind+1].push_front(xx);
freq[ind].pop_back();
}
for(auto j:kk){
vis[j]=0;
}
}
int coo=0;
for(int i=0;i<m;i++){
int co=0;
for(int j=0;j<n;j++){
if(it[j][i]==0){
co+=1;
}
}
if(co>=k){
coo+=1;
}
}
cout<<ma<<endl;
// cout<<coo+aa.a<<endl;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(it[i][j]==1){
cout<<"+";
}
else{
cout<<"-";
}
}
cout<<endl;
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |