結果
| 問題 |
No.150 "良問"(良問とは言っていない
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2016-07-21 04:49:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 851 bytes |
| コンパイル時間 | 604 ms |
| コンパイル使用メモリ | 66,968 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-11 02:01:23 |
| 合計ジャッジ時間 | 3,934 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | RE * 20 |
コンパイルメッセージ
main.cpp: In function ‘int f()’:
main.cpp:48:1: warning: no return statement in function returning non-void [-Wreturn-type]
48 | }
| ^
main.cpp:42:21: warning: ‘e1.E::ch’ may be used uninitialized in this function [-Wmaybe-uninitialized]
42 | int ch2=ch1+e1.ch;
| ^~~
ソースコード
#include <iostream>
#include <stdio.h>
#include <queue>
#include <string>
struct E{
int p,ch;
bool operator<(const E& e1)const{
if(ch!=e1.ch)return ch>e1.ch;
return p>e1.p;
}
};
int ch(std::string str,std::string word){
int res=0;
for(int i=0;i<word.size();i++){
if(str[i]!=word[i])res++;
}
return res;
}
int f(){
std::string str;
std::cin>>str;
std::priority_queue<E> pq;
int ans=-1;
for(int i=0;i+6<str.size();i++){
E e1;
e1.p=i;
e1.ch=ch(str.substr(i,7),"problem");
pq.push(e1);
}
for(int i=0;i+10<str.size();i++){
int ch1=ch(str.substr(i,4),"good");
E e1;
while(pq.empty()==false){
e1=pq.top();
if(e1.p>i+3){
break;
}
pq.pop();
}
int ch2=ch1+e1.ch;
if((ans==-1)||(ans>ch2)){
ans=ch2;
}
}
printf("%d\n",ans);
}
int main() {
int n;
std::cin>>n;
for(int i=0;i<n;i++){
f();
}
}
horiesiniti