原創 多校訓練第1輪.E——Everybody deserves a long long name【噁心人的模擬】

題目描述

In the Kingdom of Bears, the King Tommmmmmmmmmmmmmmmy has a very strange hobby: he dislike all names with length less than 1010! In fact every time he see who has a short name, he’d be so angry that he refuse to speak in the next 998244353998244353 days!

But Tommmmmmmmmmmmmmmmy the King is essential for the Kingdom of Bears, so the Minister of civil affair, Pneumonoultramicroscopicsilicovolcanoconiosis, announces that: every bear should have a long long name! Renaming is hard for bears, so Pneumonoultramicroscopicsilicovolcanoconiosis uses a sequence of methods to show the rules of renaming as follow:

If first letter of the name is not 'g', reverse the name, else append 'h' after the name.
If last letter of the name is not 'y' and first letter of the name is 'w', append 'j' after the name, else append 't' after the name.
If length of the name is not greater than 42, append 'u' after the name, else do nothing.
If last letter of the name is not 'v', reverse the name, else append 'd' after the name.
If length of the name is not greater than 43, append 'o' after the name, else append 'q' after the name.
If first letter of the name is not 'm', reverse the name, else reverse the name.
If last letter of the name is 'x', do nothing, else append 's' after the name.
If length of the name is less than 22, append 'n' after the name, else append 't' after the name.
If first letter of the name is not 'i', do nothing, else reverse the name.
If last letter of the name is 'c', append 'e' after the name, else append 'a' after the name.
If length of the name is not 42 and last letter of the name is 'v', append 'u' after the name, else do nothing.
If length of the name is not less than 47, append 'j' after the name, else reverse the name.
If first letter of the name is not 'v', append 'e' after the name, else append 'd' after the name.
If last letter of the name is 'y', append 'w' after the name, else reverse the name.
If first letter of the name is 'u', reverse the name, else append 'i' after the name.
If length of the name is not less than 32, append 'w' after the name, else do nothing.
If last letter of the name is not 'i' and first letter of the name is 'd', append 'a' after the name, else reverse the name.
If last letter of the name is not 'y', reverse the name, else do nothing.
If first letter of the name is 'y', append 'v' after the name, else reverse the name.
If length of the name is greater than 50, do nothing, else append 'm' after the name.
If last letter of the name is 't', append 'w' after the name, else append 'q' after the name.
If first letter of the name is 't', append 'e' after the name, else do nothing.
If length of the name is greater than 48, append 'l' after the name, else reverse the name.
If last letter of the name is 'y', append 'w' after the name, else reverse the name.
If length of the name is not less than 18 and first letter of the name is not 'b', reverse the name, else append 'c' after the name.
If length of the name is greater than 18, append 'y' after the name, else do nothing.
If last letter of the name is not 'g', append 'a' after the name, else reverse the name.
If first letter of the name is 'q', do nothing, else append 'i' after the name.
If last letter of the name is 'n' and length of the name is not less than 38, append 'o' after the name, else append 'v' after the name.
If first letter of the name is not 'n', do nothing, else append 'z' after the name.
If length of the name is 21 and first letter of the name is not 'm', append 'u' after the name, else append 'o' after the name.
If length of the name is 34, do nothing, else append 'z' after the name.
If first letter of the name is not 'r', reverse the name, else reverse the name.
If length of the name is greater than 25, append 'c' after the name, else reverse the name.
If first letter of the name is not 'u', append 'k' after the name, else append 'l' after the name.
If length of the name is less than 41, reverse the name, else append 'p' after the name.
If first letter of the name is not 'p', reverse the name, else append 'z' after the name.
If length of the name is less than 4 and last letter of the name is 'p', reverse the name, else append 'l' after the name.
If length of the name is not 16 and first letter of the name is 'w', append 'r' after the name, else append 'o' after the name.
If last letter of the name is 'c', append 'p' after the name, else append 'i' after the name.
If length of the name is not 20, append 'p' after the name, else reverse the name.
If last letter of the name is not 'b', reverse the name, else append 'p' after the name.
If first letter of the name is not 'c', append 'n' after the name, else append 'l' after the name.
If length of the name is not greater than 40, append 'd' after the name, else do nothing.
If first letter of the name is 'g', append 'y' after the name, else append 'i' after the name.
If last letter of the name is 'k', reverse the name, else append 'v' after the name.
If length of the name is not 20 and first letter of the name is not 'u', reverse the name, else reverse the name.
If length of the name is not greater than 46, append 'v' after the name, else append 'f' after the name.
If first letter of the name is not 'i', do nothing, else append 'z' after the name.
If length of the name is not less than 38, reverse the name, else append 'b' after the name.

But it is still very hard for bears to do the transforms precisely. So they ask you - a human who can use computer program - to solve the request. Can you help them?


輸入格式

Input contains single string s(1s50)s (1 \leq |s| \leq 50) consists of lowercase English letter - the original name your program need to operate.


輸出格式

Output the desired name in a single line.


輸入

winnie

tommmmmmmmmmmmmmmmy

pneumonoultramicroscopicsilicovolcanoconiosis


輸出

vidniansutwinnieoemqcaivozkloipvb

vpiolkcqmeoymmmmmmmmmmmmmmmmottustaiyavozniv

fpiolzoviaylqejatstpneumonoultramicroscopicsilicovolcanoconiosisqiwckpniv


說明/提示

The statement may be too narrow to show all content clearly. You are allowed to copy it from the website to local editor for convenience.


題意

  • 給你一個字符串,和50條操作,讓你輸出操作後的字符串

題解

  • QAQ,我哭了
  • 本題靈感來源於 AIM Tech Poorly Prepared Contest 裏的 Keep talking and nobody explodes 三道題,但是因爲出題人水平低所以模仿得很拙劣。
  • 本題本意是想寫一個 parser 來處理這段內容,翻譯爲代碼。
  • 當然考慮到如果作爲輸入文件的話,題目難度(相對來說)太高,因此就放了 50 句話在題面裏,希望大家各顯神通。
  • 做法有以下幾種:
    1. 喊代碼手過來好好照着抄 50 句話。代碼複雜度 O( 沒有一發 AC 的話代碼手想打人 )。
    2. 寫一個 parser 來翻譯。代碼複雜度 O( 還行 )
    3. 使用編輯器的查找替換功能刪掉一些無用的話,比如 ‘of the name’, ‘after the name’ 啥的,再抄 / 用 parser 來翻譯。代碼複雜度 O( 感覺可以 )。
    4. 進一步替換,發現這個語言的順序和大多數程序語言非常接近,甚至在一系列替換後可以除了括號
      都換好,只需要改 50 個分號。代碼複雜度 O(50)。
  • 下面給出一種可能的替換爲 C++ 的替換序列:
    • of ther name,after ther name,do nothing → ×
    • is greater than, is not greater than, is less than, is not less than → >, <=, <, >=
    • is, is not → ==, ! =
    • first letter, last letter → name.front(), name.back()
    • append → name +=
    • reverse the name → reverse(name.begin(), name.end())
    • If → if (
    • , → ;

AC-Code

#include <bits/stdc++.h>
using namespace std;
int main() {
	string name;
	cin >> name;
	if ((name.front() != 'g')) reverse(name.begin(), name.end());
	else name += 'h';
	if ((name.back() != 'y') && (name.front() == 'w')) name += 'j';
	else name += 't';
	if (!(name.size() > 42)) name += 'u';
	else;
	if ((name.back() != 'v')) reverse(name.begin(), name.end());
	else name += 'd';
	if (!(name.size() > 43)) name += 'o';
	else name += 'q';
	if ((name.front() != 'm')) reverse(name.begin(), name.end());
	else reverse(name.begin(), name.end());
	if ((name.back() == 'x'));
	else name += 's';
	if ((name.size() < 22)) name += 'n';
	else name += 't';
	if ((name.front() != 'i'));
	else reverse(name.begin(), name.end());
	if ((name.back() == 'c')) name += 'e';
	else name += 'a';
	if (!(name.size() == 42) && (name.back() == 'v')) name += 'u';
	else;
	if (!(name.size() < 47)) name += 'j';
	else reverse(name.begin(), name.end());
	if ((name.front() != 'v')) name += 'e';
	else name += 'd';
	if ((name.back() == 'y')) name += 'w';
	else reverse(name.begin(), name.end());
	if ((name.front() == 'u')) reverse(name.begin(), name.end());
	else name += 'i';
	if (!(name.size() < 32)) name += 'w';
	else;
	if ((name.back() != 'i') && (name.front() == 'd')) name += 'a';
	else reverse(name.begin(), name.end());
	if ((name.back() != 'y')) reverse(name.begin(), name.end());
	else;
	if ((name.front() == 'y')) name += 'v';
	else reverse(name.begin(), name.end());
	if ((name.size() > 50));
	else name += 'm';
	if ((name.back() == 't')) name += 'w';
	else name += 'q';
	if ((name.front() == 't')) name += 'e';
	else;
	if ((name.size() > 48)) name += 'l';
	else reverse(name.begin(), name.end());
	if ((name.back() == 'y')) name += 'w';
	else reverse(name.begin(), name.end());
	if (!(name.size() < 18) && (name.front() != 'b')) reverse(name.begin(), name.end());
	else name += 'c';
	if ((name.size() > 18)) name += 'y';
	else;
	if ((name.back() != 'g')) name += 'a';
	else reverse(name.begin(), name.end());
	if ((name.front() == 'q'));
	else name += 'i';
	if ((name.back() == 'n') && !(name.size() < 38)) name += 'o';
	else name += 'v';
	if ((name.front() != 'n'));
	else name += 'z';
	if ((name.size() == 21) && (name.front() != 'm')) name += 'u';
	else name += 'o';
	if ((name.size() == 34));
	else name += 'z';
	if ((name.front() != 'r')) reverse(name.begin(), name.end());
	else reverse(name.begin(), name.end());
	if ((name.size() > 25)) name += 'c';
	else reverse(name.begin(), name.end());
	if ((name.front() != 'u')) name += 'k';
	else name += 'l';
	if ((name.size() < 41)) reverse(name.begin(), name.end());
	else name += 'p';
	if ((name.front() != 'p')) reverse(name.begin(), name.end());
	else name += 'z';
	if ((name.size() < 4) && (name.back() == 'p')) reverse(name.begin(), name.end());
	else name += 'l';
	if (!(name.size() == 16) && (name.front() == 'w')) name += 'r';
	else name += 'o';
	if ((name.back() == 'c')) name += 'p';
	else name += 'i';
	if (!(name.size() == 20)) name += 'p';
	else reverse(name.begin(), name.end());
	if ((name.back() != 'b')) reverse(name.begin(), name.end());
	else name += 'p';
	if ((name.front() != 'c')) name += 'n';
	else name += 'l';
	if (!(name.size() > 40)) name += 'd';
	else;
	if ((name.front() == 'g')) name += 'y';
	else name += 'i';
	if ((name.back() == 'k')) reverse(name.begin(), name.end());
	else name += 'v';
	if (!(name.size() == 20) && (name.front() != 'u')) reverse(name.begin(), name.end());
	else reverse(name.begin(), name.end());
	if (!(name.size() > 46)) name += 'v';
	else name += 'f';
	if ((name.front() != 'i'));
	else name += 'z';
	if (!(name.size() < 38)) reverse(name.begin(), name.end());
	else name += 'b';
	cout << name << endl;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章