結果
問題 | No.150 "良問"(良問とは言っていない |
ユーザー |
|
提出日時 | 2020-04-22 18:46:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 609 bytes |
コンパイル時間 | 2,249 ms |
コンパイル使用メモリ | 194,392 KB |
最終ジャッジ日時 | 2025-01-09 22:36:53 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:31:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 31 | int q; scanf("%d",&q); rep(_,q) solve(); | ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; void solve(){ string s; cin>>s; int n=s.length(); int ans=11; rep(i,n) for(int j=i+4;j+7<=n;j++) { int cost=11; if(s[i ]=='g') cost--; if(s[i+1]=='o') cost--; if(s[i+2]=='o') cost--; if(s[i+3]=='d') cost--; if(s[j ]=='p') cost--; if(s[j+1]=='r') cost--; if(s[j+2]=='o') cost--; if(s[j+3]=='b') cost--; if(s[j+4]=='l') cost--; if(s[j+5]=='e') cost--; if(s[j+6]=='m') cost--; ans=min(ans,cost); } printf("%d\n",ans); } int main(){ int q; scanf("%d",&q); rep(_,q) solve(); return 0; }