1. 程式人生 > >Codeforces Round #487 (Div. 2) C - A Mist of Florescence

Codeforces Round #487 (Div. 2) C - A Mist of Florescence

-- pac != using ace work 矩形 col ()

C - A Mist of Florescence

把50*50的矩形拆成4塊

#include<bits/stdc++.h>
using namespace std;
int a[10],b[10];
int mp[1000][1000];
void init(int x,int y,int xx,int yy,int va){
  for(int j=x;j<=xx;j++){
     for(int k=y;k<=yy;k++){
        mp[j][k]=va;
     }
  }
}
void work(int x,int y,int xx,int
yy,int va,int i){ if(b[va]>=a[va]) return ; for(int j=x;j<=xx;j+=2){ for(int k=y;k<=yy;k++){ if(mp[j][k]==i&&mp[j+1][k]!=va&&mp[j-1][k]!=va&&mp[j][k-1]!=va&&mp[j][k+1]!=va){ mp[j][k]=va; b[va]++; if(b[va]>=a[va]) return
; } } } } int main(){ for(int j=1;j<=4;j++){ cin>>a[j]; a[j]--; b[j]=0; } init(1,1,24,24,1); init(1,25,24,50,2); init(25,1,50,24,3); init(25,25,50,50,4); for(int j=1;j<=4;j++){ if(b[j]<a[j]){ work(2,2,23,23
,j,1); work(1+1,25+1,24-1,50-1,j,2); work(25+1,1+1,50-1,24-1,j,3); work(25+1,25+1,50-1,50-1,j,4); } } cout<<"50 50"<<endl; for(int j=1;j<=50;j++){ for(int k=1;k<=50;k++){ if(mp[j][k]==1){ cout<<"A"; } if(mp[j][k]==2){ cout<<"B"; } if(mp[j][k]==3){ cout<<"C"; } if(mp[j][k]==4){ cout<<"D"; } } cout<<endl; } }

Codeforces Round #487 (Div. 2) C - A Mist of Florescence