結果
問題 |
No.380 悪の台本
|
ユーザー |
![]() |
提出日時 | 2025-04-18 16:03:39 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,277 bytes |
コンパイル時間 | 3,220 ms |
コンパイル使用メモリ | 281,436 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-04-18 16:03:44 |
合計ジャッジ時間 | 4,240 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 1 WA * 6 RE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:47:29: warning: ‘pos’ may be used uninitialized [-Wmaybe-uninitialized] 47 | for(ll i=0;i<pos;i++){ | ~^~~~ main.cpp:39:20: note: ‘pos’ was declared here 39 | 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(){ 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" */