NC19325. 游戏
描述
输入描述
题目有多组数据
第一行一个整数t,表示数据组数
对于每组数据,第一行两个整数n,m,接下来n行每行m个字符
输出描述
输出共t行,每行一个字符串表示答案
示例1
输入:
2 3 3 RGG BBG RRR 3 3 GRB RGR RBG
输出:
dreagonm fengxunling
C++11(clang++ 3.9) 解法, 执行用时: 41ms, 内存消耗: 1384K, 提交时间: 2019-10-13 08:35:06
#include<cstdio> const int N=1e3+10; char s[N][N]; int n,m,t; int main() { scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); for(int i=0; i<n; i++)scanf("%s",s[i]); if(s[0][0]=='B')puts("BLUESKY007"); else if(s[0][0]=='G')puts("fengxunling"); else puts("dreagonm"); } return 0; }
Python3(3.5.2) 解法, 执行用时: 100ms, 内存消耗: 3640K, 提交时间: 2020-06-16 23:48:35
t = int(input()) for i in range(t): r,c = map(int,input().split()) nums = [] for j in range(r): nums.append(str(input())) if nums[0][0] == "B": print("BLUESKY007") elif nums[0][0] == "G": print("fengxunling") else: print("dreagonm")
C++14(g++5.4) 解法, 执行用时: 38ms, 内存消耗: 1272K, 提交时间: 2020-06-16 21:27:28
#include<cstdio> char c[1010][1010]; int t,n,m,i; int main() { scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); for(i=0;i<n;i++) scanf("%s",c[i]); if(c[0][0]=='R') printf("dreagonm\n"); else if(c[0][0]=='G') printf("fengxunling\n"); else printf("BLUESKY007\n"); } }