ONECODE天梯C : 月份矩阵

C : 月份矩阵 时间限制: 1000 MS 内存限制: 132000 KB 提交总数: 26 AC总数: 20 问题描述 杜拉拉今天带入职新员工去素质拓展,第一个项目是一个团队合作游戏。 现在拉拉将新员工平均分成t(t=>1, t<=15)组,当拉拉说出数字n(n>=1,n <=15) 和数字m(m>=1, m <= 15) 则每组需要在规定时间内选出n*m个人排成n行m列的矩阵,并且相邻的两个人之间出生月份不能相同。现在拉拉 需要你的帮助,判定各组排列的矩阵是否符合要求。(假定每组都能在规定时间内排出n行m列的矩阵) 输入格式 第一行输入三个正整数t(t>0,t<15),n(n>=1,n <=15),m(m>=1, m <= 15), 表示有t组新员工,接下来输入每组新员工n行m列的矩阵对应的人的出生月份。

输出格式 一次输出t行,依次对应各组排列结果:RIGHT表示矩阵符合要求;WRONG表示矩阵不符合要求 样例输入 3 2 3 8 7 8 2 12 11 8 11 8 2 12 11 8 7 8 8 12 11 样例输出 RIGHT RIGHT WRONG

#include<bits/stdc++.h>
using namespace std;
int a[20][20][20],t,k,l,i,p,w;
int quq(int e)
{
    for (int u=1;u<=k;u++)
    {
        for (int q=1;q<=l;q++)
        {

            if (a[e][u][q]==a[e][u+1][q]||a[e][u][q]==a[e][u-1][q]||a[e][u][q]==a[e][u][q+1]||a[e][u][q]==a[e][u-1][q]||a[e][u][q]==a[e][u][q+1]||a[e][u][q]==a[e][u-1][q]||a[e][u][q]==a[e][u][q-1]) return 0;
        }
    }
    return 1;
}
int main()
{
    cin>>t>>k>>l;
    for (i=1;i<=t;i++)
    {
        for (p=1;p<=k;p++)
        {
            for (w=1;w<=l;w++)
            {
                cin>>a[i][p][w];
            }
        }
    }
    for (i=1;i<=t;i++)
    {
        if (quq(i)) cout<<"RIGHT"<<endl;

        else cout<<"WRONG"<<endl;
    }
    return 0;
}

有什么感想?

 发射评论! 

猜你喜欢

转载自blog.csdn.net/oj_onecode/article/details/82528423
今日推荐