AT5694 [AGC041C] Domino Quality(构造)

    科技2024-07-23  66

    https://www.luogu.com.cn/problem/AT5694

    题意:

    n ∗ n n*n nn,放 1 ∗ 2 1*2 12牌,要求每行每列的牌数相同,输出方案。

    代码:

    每行每列都是3个,构造出4、5、6、7,后面的直接主对角线放上就行

    3的时候每行每列只能是1或者2,不能3。

    代码:

    /* * Author : Jk_Chen * Date : 2020-10-07-13.08.13 */ #include<bits/stdc++.h> using namespace std; #define LL long long #define LD long double #define rep(i,a,b) for(int i=(int)(a);i<=(int)(b);i++) #define per(i,a,b) for(int i=(int)(a);i>=(int)(b);i--) #define mmm(a,b) memset(a,b,sizeof(a)) #define pb push_back #define pill pair<int, int> #define fi first #define se second void test(){cerr<<"\n";} template<typename T,typename... Args>void test(T x,Args... args){cerr<<"> "<<x<<" ";test(args...);} const LL mod=1e9+7; const int maxn=1e5+9; const int inf=0x3f3f3f3f; LL rd(){ LL ans=0; char last=' ',ch=getchar(); while(!(ch>='0' && ch<='9'))last=ch,ch=getchar(); while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar(); if(last=='-')ans=-ans; return ans; } #define rd rd() /*_________________________________________________________begin*/ string x[10][10]; int main(){ ios::sync_with_stdio(false); cin.tie(0); int i=0; x[3][i]=".aa";i++; x[3][i]="a..";i++; x[3][i]="a..";i++; i=0; x[4][i]="abcc";i++; x[4][i]="abdd";i++; x[4][i]="ccab";i++; x[4][i]="ddab";i++; i=0; x[5][i]="abbcc";i++; x[5][i]="ac..d";i++; x[5][i]="bc..d";i++; x[5][i]="b.eea";i++; x[5][i]="ccbba";i++; i=0; x[6][i]="aab.zz";i++; x[6][i]="d.bz..";i++; x[6][i]="dccz..";i++; x[6][i]=".zzaab";i++; x[6][i]="z..d.b";i++; x[6][i]="z..dcc";i++; i=0; x[7][i]="az..z..";i++; x[7][i]="az..z..";i++; x[7][i]="b.zz.zz";i++; x[7][i]="bz..z..";i++; x[7][i]="cz..z..";i++; x[7][i]="c.zz.zz";i++; x[7][i]=".ccbbaa";i++; int n=rd; if(n<3){ cout<<"-1"<<endl; } else if(n==3){ rep(i,0,2) cout<<x[3][i]<<endl; } else{ int pre=0; while(n>7){ n-=4; rep(i,0,3){ rep(_,1,pre)cout<<'.'; cout<<x[4][i]; rep(_,1,n)cout<<'.'; cout<<endl; } pre+=4; } assert(n>=4&&n<=7); rep(i,0,n-1){ rep(_,1,pre)cout<<'.'; cout<<x[n][i]; cout<<endl; } } return 0; } /*_________________________________________________________end*/
    Processed: 0.010, SQL: 8