列表

详情


NC205092. Hinnjaku

描述

"I learned one thing from my short life that the ability of human-being is limited. The more one digs into strategy, the more possibly he would realize this point. Therefore, I won't be a human-being anymore, JOJO!"

During the outbreak of the COVID-19, HamsterW was bored at home after reading the manga drawn by E Yu, therefore he pick up an interesting bangumi named JOJO's Wonderful Adventure:

Now the bangumi comes to the most thrilling part: the battle between JOJO and Dio. The rule of their battle is as follows:

In the initial state, JOJO and Dio both have a equal health point represented by . Whose HP returns to zero first is regarded as the defeated one. And if the duel is completed and no one has the zero HP, the one who has more HP will win the duel.

Because their attacks are through their special abilities named stand and normal people are not able to see them, here we will represent JOJO and Dio's attacks as two strings ,. the length of the two stings is equal to , which is the seconds their battle lasts. The strings will only contain lower case characters 'a', 'd','l', 'm', 'o', 'r', 'u', 'w', 'z'. Every character in the string stands an action their stands make, and the character is the action of the second.

Fighting time goes by with the appearance of characters. Every time when last three letters form a string "ora" in JOJO's string, JOJO's stand named Star Platinum finish an attack and Dio's HP decreases by one point. Meanwhile, when last four letters form a string "muda" in Dio's string, it means that DIO's stand named The World makes an attack, causing JOJO's HP decreases by one point.

Apart from normal attacks, they also have the superpower called "zawaluduo" which can pause the time. When one side uses "zawaluduo", the other side will pause attack (i.e. The attack will be interrupted and won't take effect). If zawaluduo appears in one's string, it means that he triggers this ability at the time letter o represents for.

Since "ora" is shorter than "muda", Dio is obviously at a disadvantage. But Dio's superpower is stronger than JOJO.

If JOJO uses the "zawaluduo", it will have a killing effect on Dio, and Dio's HP will turn to zero.

If Dio uses this ability, it will also have a killing effect on JOJO, and JOJO's HP will turn to zero.

Since JOJO's superpower is weaker than Dio, if JOJO and Dio use this superpower at the same time, it will be judged that Dio will try the superpower first and therefore JOJO is killed at once.

Finally, according to the strings representing their battle, you need to anticipate the result.

If JOJO wins, you need to output "Wryyyyy".
If Dio wins, you need to output "Hinnjaku".
If there is a tie, you need to output "Kono Dio da". (This means their HP decreases to zero at the same time, or they have equal HP which is greater than zero after the duel.)

输入描述

The input contains multiple cases. The first line contains an nonnegative integer **** the number of test cases.

Each case is lead by a line contains two positive number separated by space. The first number is  representing the length of two strings. The second number is  representing the health points of JOJO and Dio.

The second line contain a string  representing JOJO's attack.

The third line contain a string  representing Dio's attack.

It is guaranteed that

输出描述

For each test case, print a number one line contain a string.
If JOJO wins, you need to output "Wryyyyy".
If Dio wins, you need to output "Hinnjaku".
If there is a tie, you need to output "Kono Dio da".

(All the output contains no quotes.)

示例1

输入:

4
12 3
ororaoraorao
mudamudamuda
13 1000
zawaluduoorao
zawaluduomuda
12 100
oooraoraorao
mudamudamuda
12 3
oraoraoraora
zawaluduomud

输出:

Wryyyyy
Hinnjaku
Kono Dio da
Hinnjaku

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++11(clang++ 3.9) 解法, 执行用时: 163ms, 内存消耗: 3816K, 提交时间: 2020-04-27 10:40:50

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

const int maxn=1e5+10;
char s[maxn],t[maxn];
int n,h1,h2;


void solve()
{
	cin>>n>>h1;
	cin>>s+1>>t+1;
	int flag;
	h2=h1;
	string tmp="zawaluduo";
	for( int i=3;i<=n && h1 && h2 ;i++ )
	{
		if( i>=9 )
		{
			int f=1;
			for( int j=0,k=i-8;j<9;j++,k++ ) if( t[k]!=tmp[j] ) f=0;
			if( f ) 
			{
				h1=0;break;
			} 
			f=1;
			for( int j=0,k=i-8;j<9;j++,k++ ) if( s[k]!=tmp[j] ) f=0;
			if( f ) 
			{
				h2=0;break;
			}
		}
		if( s[i-2]=='o' && s[i-1]=='r' && s[i]=='a' ) h2--;
		if( i<4 ) continue;
		if( t[i-3]=='m' && t[i-2]=='u' && t[i-1]=='d' && t[i]=='a' ) h1--; 
	}
	if( h1>h2 ) puts("Wryyyyy");
	else if( h2>h1 ) puts("Hinnjaku");
	else puts("Kono Dio da");
} 

int main()
{
	int t;
	cin>>t;
	while( t-- ) solve();
}

C++14(g++5.4) 解法, 执行用时: 167ms, 内存消耗: 504K, 提交时间: 2020-04-26 14:55:49

#include<bits/stdc++.h>

using namespace std;
const int N = 2e5+10;

int n, m;
char s[N], t[N];
char mp[10][12] = {"Wryyyyy", "Hinnjaku", "Kono Dio da"};
int main()
{
    int _;
    scanf("%d", &_);
    while(_--)
    {
        scanf("%d%d %s %s", &n, &m, &s, &t);
        int HP1 = m, HP2 = m;
        for(int i = 0;i < n&&HP1&&HP2; ++i)
        {
            if(i>=8&&!strncmp(t+(i-8), "zawaluduo", 9))
            {HP1=0; break; }
            if(i>=8&&!strncmp(s+(i-8), "zawaluduo", 9))
            {HP2=0; break; }
            if(i>=2&&!strncmp(s+(i-2), "ora", 3)) HP2--;
            if(i>=3&&!strncmp(t+(i-3), "muda", 4)) HP1--;
        }
        int flag = (HP1==HP2)?2:((HP1>HP2)?0:1);
        printf("%s\n", mp[flag]);
    }
    return 0;
}

上一题