【jzoj4764】【Brothers】【模拟】

题目大意

在遥远的西方有一个古老的王国,国王将他的王国分成了网格状,每一块称之为一个城市。在国王临死前,他将这些城市分给了自己的N个儿子(编号为0到N-1)。然而这N个王子的关系不是很好,0讨厌1,1讨厌2,2讨厌3……N-1讨厌0。
在国王死后,这种不好的关系使得王子之间爆发了战争。战斗只会在相邻的两个城市之间爆发(共有一条边称之为相邻),并且只有当A讨厌B时,A才会对B发起战斗,结果必定是A获得这次战斗的胜利。当一方胜利后,他所进攻的城市就会变成进攻方的。许多战斗是同时发生的,我们称之为一场战役。当多场战役发生之后,剩下的王子将不再发生战争。
例如,如果有3个王子,那么战斗过程如下所示:

这里写图片描述

解题思路

暴力模拟

code

#include<set>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LF double
#define LL long long
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define fd(i,j,k) for(int i=j;i>=k;i--)
using namespace std;
int const maxn=100,inf=2147483647;
int n,r,c,K,map[maxn+10][maxn+10],tag[maxn+10][maxn+10],w[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int main(){
    freopen("d.in","r",stdin);
    freopen("d.out","w",stdout);
    scanf("%d%d%d%d",&n,&r,&c,&K);
    fo(i,1,r)
        fo(j,1,c)
            scanf("%d",&map[i][j]);
    fo(k,1,K){
        fo(i,1,r)
            fo(j,1,c)
                fo(l,0,3)
                    if((map[i][j]+1==map[i+w[l][0]][j+w[l][1]])||((map[i][j]==n-1)&&(!map[i+w[l][0]][j+w[l][1]])))tag[i+w[l][0]][j+w[l][1]]=1;
        fo(i,1,r)
            fo(j,1,c){
                map[i][j]-=tag[i][j];
                if(map[i][j]<0)map[i][j]=n-1;
                tag[i][j]=0;
            }
    }
    fo(i,1,r){
        fo(j,1,c)
            printf("%d ",map[i][j]);
        printf("\n");
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
马丁路德金的"I have a dream"节选存放在"freedom.txt"中: I have a dream that one day this nation will rise up, live up to the true meaning of its creed: “We hold these truths to be self-evident; that all men are created equal.” I have a dream that one day on the red hills of Georgia the sons of former slaves and the sons of former slave-owners will be able to sit down together at the table of br otherhood. I have a dream that one day even the state of Mississippi, a state sweltering with th e heat of injustice, sweltering with the heat of oppression, will be transformed into an oasis of freedom and justice. I have a dream that my four children will one day live in a nation where they will no t be judged by the color if their skin but by the content of their character. I have a dream today. I have a dream that one day down in Alabama with its governor having his lips drippin g with the words of interposition and nullification, one day right down in Alabama li ttle black boys and black girls will be able to join hands with little white boys and white girls as sisters and brothers. I have a dream today. I have a dream that one day every valley shall be exalted, every hill and mountain sh all be made low, the rough places will be made plain, and the crooked places will be made straight, and the glory of the Lord shall be revealed, and all flesh shall see i t together. 编程实现词汇表,计算每一个单词出现的次数,大小写不区分,输出到"dic.txt" 文件保存。
最新发布
06-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值