CSU 1202 Stone-scissors-cloth (模拟)

1202: Stone-scissors-cloth

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 293  Solved: 141
[ Submit][ Status][ Web Board]

Description

现在一共有N个人(分别记为1, 2, …, N)在玩剪刀石头布,如果知道他们每个人都出了什么,你能找出来谁是winner吗?

当且仅当一个人可以赢其他所有人时,才称这个人是winner。

我们将剪刀记作2,石头记作0,布记作5,那么胜负关系就应当是2能赢5,5能赢0,0能赢2。

Input

输入数据的第一行包含一个整数T ( 1 <= T <= 150),表示接下来一共有T组测试数据。

每组测试数据的第一行包含一个整数N (2 <= N <= 100000)表示一共有N个人在玩剪刀石头布,接下来一行一共有N个数,每个数均为0、2或5中的某一个,依次描述了这N个人分别出了什么,其中第i个整数描述了第i个人出了什么。

Output

对于每组数据,用一行输出一个整数表示winner是第几个人([1, N]中的某个整数)。

如果不存在winner,则用一行输出“No winner”(不包括引号)。

Sample Input

3
3
5 5 2
3
2 0 0
3
0 2 5

Sample Output

3
No winner
No winner

HINT

Source

CSU Monthly 2013 Apr.


题意:

告诉你石头剪刀布的规则,问是否有唯一一人获胜,有输出编号,没有输出“No winner”。

思路:

简单模拟


/*************************************************************************
	> File Name: B.cpp
	> Author: BSlin
	> Mail:  
	> Created Time: 2013年10月03日 星期四 12时15分26秒
 ************************************************************************/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#define MP make_pair
#define INF (1<<30)
#define PI acos(-1.0)
#define esp 1e-8
const int dx[4]={0,0,0,0};
using namespace std;
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#if defined (_WIN32) || defined (__WIN32) || defined (WIN32) || defined (__WIN32__)
#define LL __int64
#define LLS "%" "I" "6" "4" "d"
#else
#define LL long long
#define LLS "%" "l" "l" "d"
#endif



#define M 100010

struct node {
    int x,id;
}data[M];

int cnt[5];

int main(int argc, char** argv) {
    //read;
    int t,n;
    scanf("%d",&t);
    while(t--) {
        memset(cnt,0,sizeof(cnt));
        scanf("%d",&n);
        for(int i=1; i<=n; i++) {
            scanf("%d",&data[i].x);
            data[i].id = i;
            if(data[i].x == 0) {
                cnt[0] ++;
            }
            else if(data[i].x == 2) {
                cnt[1] ++;
            }
            else if(data[i].x == 5) {
                cnt[2] ++;
            }
        }
        if(cnt[0] != 0 && cnt[1] != 0 && cnt[2] != 0) {
            printf("No winner\n");
            continue;
        }
        else if(cnt[0] == 1 && cnt[1] != 0 && cnt[2] == 0) {
            for(int i=1; i<=n; i++) {
                if(data[i].x == 0) {
                    printf("%d\n",data[i].id);
                    break;
                }
            }
        }
        else if(cnt[0] == 0 && cnt[1] == 1 && cnt[2] != 0) {
            for(int i=1; i<=n; i++) {
                if(data[i].x == 2) {
                    printf("%d\n",data[i].id);
                    break;
                }
            }
        }
        else if(cnt[0] != 0 && cnt[1] == 0 && cnt[2] == 1) {
            for(int i=1; i<=n; i++) {
                if(data[i].x == 5) {
                    printf("%d\n",data[i].id);
                    break;
                }
            }
        }
        else printf("No winner\n");
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值