結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-04-18 16:03:12 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,349 bytes |
| コンパイル時間 | 2,955 ms |
| コンパイル使用メモリ | 282,984 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-04-18 16:03:16 |
| 合計ジャッジ時間 | 3,761 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:36:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
36 | freopen("dialogue.in","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:37:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
37 | freopen("dialogue.out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:49:29: warning: ‘pos’ may be used uninitialized [-Wmaybe-uninitialized]
49 | for(ll i=0;i<pos;i++){
| ~^~~~
main.cpp:41:20: note: ‘pos’ was declared here
41 | ll pos;
| ^~~
ソースコード
#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;
for(ll i=0;i<st.size();i++){
if(st[i]==' '){
pos=i;
break;
}
}
// 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"
*/
vjudge1