結果

問題 No.380 悪の台本
ユーザー vjudge1
提出日時 2025-04-18 16:23:02
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,285 bytes
コンパイル時間 3,709 ms
コンパイル使用メモリ 282,452 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-18 16:23:07
合計ジャッジ時間 3,950 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 2 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string ans[]={"WRONG!\n","CORRECT (maybe)\n"};
bool fh(char c){
	if(isalpha(c)||isdigit(c))return 0;
	return 1;
}
ll getsize(string s){
	ll sz=s.size();
	for(ll i=sz-1;i>=0;i--){
		if(fh(s[i]))sz--;
		else break;
	}
	return sz;
}
string ed(string s,ll x){
	ll sz=getsize(s);
	string res="";
	for(ll i=sz-1,cnt=1;i>=0&&cnt<=x;i--,cnt++){
		res+=s[i];
//		cout<<i<<" "<<cnt<<endl;
	}
	reverse(res.begin(),res.end());
	return res;
}
bool solve(string s,string t){
	if(s=="digi"&&ed(t,3)=="nyo"&&t.size()-getsize(t)<=3)return 1;
	if(s=="petit"&&ed(t,3)=="nyu"&&t.size()-getsize(t)<=3)return 1;
	if(s=="rabi"&&t.size()-getsize(t)>=1)return 1;
	if(s=="gema"&&ed(t,4)=="gema"&&t.size()-getsize(t)<=3)return 1;
	if(s=="piyo"&&ed(t,3)=="pyo"&&t.size()-getsize(t)<=3)return 1;
	return 0;
}
int main(){
//	freopen("dialogue.in","r",stdin);
//	freopen("dialogue.out","w",stdout);
	string st;
	while(getline(cin,st)){
		string s="",t="";
		ll pos=st.find(' ');
//		cout<<pos<<endl;
		for(ll i=0;i<pos;i++){
			s+=st[i];
		}
		for(ll i=pos+1;i<st.size();i++){
			t+=st[i];
		}
//		cout<<s<<" "<<t<<endl;
		for(ll i=0;i<t.size();i++){
			t[i]=tolower(t[i]);
		}
		cout<<ans[solve(s,t)];
	}
}
/*
"digi"?"petit"??rabi"??gema"??piyo"
*/
0