繁华模拟赛 奇怪的棋

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 205;
struct chs{
    int y;
    int x;

};
chs orz[3][maxn*maxn];
int n,vis[maxn][maxn],cnt_op,cnt_no,cnt_ok;
int dy,dx,ans;
void input(){
    cin>>n;
    char cmd;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            scanf("%c",&cmd);
            while(cmd != ‘o‘ && cmd != ‘x‘ && cmd != ‘.‘) scanf("%c",&cmd);
            if(cmd == ‘o‘){
                cnt_op++;
                orz[0][cnt_op].y = i;
                orz[0][cnt_op].x = j;
            }else if(cmd == ‘x‘){
                cnt_ok++;
                orz[1][cnt_ok].y = i;
                orz[1][cnt_ok].x = j;
            }else if(cmd == ‘.‘){
                cnt_no++;
                orz[2][cnt_no].y = i;
                orz[2][cnt_no].x = j;
            }
        }
    }
}
void get_d(int y,int x,int ny,int nx){
    dy = n + ny - y;
    dx = n + nx - x;
}
void get_no(){
    for(int i = 1;i <= cnt_no;i++){
        for(int j = 1;j <= cnt_op;j++){
            get_d(orz[0][j].y,orz[0][j].x,orz[2][i].y,orz[2][i].x);
            vis[dy][dx] = 2;
        }
    }
}
bool get_ok(int dep){
    if(dep > cnt_ok){
        cout<<"YES"<<endl;
        for(int i = 1;i <= 2 * n - 1;i++){
            for(int j = 1;j <= 2 * n - 1;j++){
                if(i == n && j == n) printf("o");
                else if(vis[i][j] == 2) printf(".");
                else printf("x");
            }
            printf("\n");
        }
        return true;
    }
    int ndy,ndx;
    for(int i = 1;i <= cnt_op;i++){
        get_d(orz[0][i].y,orz[0][i].x,orz[1][dep].y,orz[1][dep].x);
        ndy = dy;
        ndx = dx;
        if(vis[ndy][ndx] != 2){
            vis[ndy][ndx] = 1;
            if(get_ok(dep+1)) return true;
            vis[ndy][ndx] = 0;
        }
    }
    return false;
}
int main(){
    freopen("chess.in","r",stdin);
    freopen("chess.out","w",stdout);
    input();
    get_no();
    if(!get_ok(1)) cout<<"NO";
    return 0;
}

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstdlib>
#include<string>
#include<bitset>
#define INF 1000000000
#define N 100005
#define fi first
#define se second
#define debug(x) cout<<#x<<"="<<x<<endl
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
int z,n,ans[105][105];
char mp[55][55];
bool vis[55][55];
bool check(int x,int y)
{
    if(x>0&&y>0&&x<=n&&y<=n)
        return 1;
    return 0;
}
int main()
{
    int i,j,r,c,now,tx,ty;
    freopen("chess.in","r",stdin);
    freopen("chess.out","w",stdout);
    cin>>n;
    for(i=1;i<=n;i++)
        scanf("%s",mp[i]+1);
    for(i=-n+1;i<n;i++)
        for(j=-n+1;j<n;j++)
        {
            now=0;
            for(r=1;r<=n;r++)
                for(c=1;c<=n;c++)
                    if(mp[r][c]==‘o‘)
                    {
                        tx=r+i,ty=c+j;
                        if(check(tx,ty))
                            if(mp[tx][ty]==‘.‘)
                                if(!now)
                                    now=-1;
                    }
            ans[i+n][j+n]=now;
            if(now!=-1)
            {
                for(r=1;r<=n;r++)
                for(c=1;c<=n;c++)
                    if(mp[r][c]==‘o‘)
                    {
                        tx=r+i,ty=c+j;
                        if(check(tx,ty))
                            vis[tx][ty]=1;
                    }
            }
        }
    for(r=1;r<=n;r++)
        for(c=1;c<=n;c++)
            if(mp[r][c]==‘x‘&&!vis[r][c])
            {
                printf("NO\n");
                return 0;
            }
    printf("YES\n");
    for(i=1;i<n*2;i++)
    {
        for(j=1;j<n*2;j++)
        {
            if(i==n&&j==n)
            {
                printf("o");
                continue;
            }
            if(ans[i][j]<0)
                printf(".");
            else printf("x");
        }
        cout<<endl;
    }
    return 0;
}
// davidlee1999WTK 2015/
// srO myk Orz
//ios::sync_with_stdio(false);
时间: 2024-08-08 12:36:46

繁华模拟赛 奇怪的棋的相关文章

[繁华模拟赛]Evensgn 剪树枝

Evensgn 剪树枝 题目 繁华中学有一棵苹果树.苹果树有 n 个节点(也就是苹果),n − 1 条边(也就 是树枝).调皮的 Evensgn 爬到苹果树上.他发现这棵苹果树上的苹果有两种:一 种是黑苹果,一种是红苹果.Evensgn 想要剪掉 k 条树枝,将整棵树分成 k + 1 个 部分.他想要保证每个部分里面有且仅有一个黑苹果.请问他一共有多少种剪树枝 的方案? INPUT 第一行一个数字 n,表示苹果树的节点(苹果)个数. 第二行一共 n − 1 个数字 p0, p1, p2, p3,

繁华模拟赛 Evensgn的债务

#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> #define ll int using namespace std; const int maxn = 1000005; ll read(){ ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(

繁华模拟赛 ljw分雕塑

/* 用f[i][k]表示考虑到第i个雕塑,分成k组,可不可行(这是一个bool类型的数组) 转移: f[i][k]=f[j][k-1],sum[i]-sum[j]合法 */ #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; typedef long long ll; const int max_n = 2010;

繁华模拟赛 找十字架

#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> using namespace std; int n; char s[205][205],cmd; int main(){ freopen("puzzle.in","r",stdin); freopen("puzzle

繁华模拟赛 Vincent的城堡

#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> #define ll long long using namespace std; const ll mod = 1000000007; ll n,k,c[20][20]; ll ansa,ansb,ans; void get_c(){ for(int i = 1;i

繁华模拟赛 Evensgn玩序列

#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> using namespace std; const int maxn = 5000; int n,a[maxn],b[maxn],c[maxn],rka[maxn],rkb[maxn],rkc[maxn]; bool visa[maxn],visb[maxn],vi

繁华模拟赛 ljw搭积木

#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> using namespace std; const int maxn = 6005; int n,x[maxn]; int cmd,cnt,ans,max_x; int main(){ freopen("box.in","r"

繁华模拟赛 Vicent坐电梯

/*n<=5000­这样就不能用O(n)的转移了,而是要用O(1)的转移.­注意我们每次的转移都来自一个连续的区间,而且我们是求和­区间求和?­前缀和!­令sum[step][i]表示f[step][1~i]的和­还是以B下侧为例­ f[step][i]=sum[step-1][i-1]+sum[step-1][k]-sum[step-1][i] */#include <cstdio> #include <cstring> #include <cstdlib> #

繁华模拟赛 Evensgn剪树枝

#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> #include<cmath> #define ll long long using namespace std; const int maxn = 100005; const ll mod = 1000000007; struct edge{ int t