結果
| 問題 |
No.150 "良問"(良問とは言っていない
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-11-03 10:46:29 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,025 bytes |
| コンパイル時間 | 637 ms |
| コンパイル使用メモリ | 57,944 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-11 01:57:37 |
| 合計ジャッジ時間 | 1,923 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:38:29: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
38 | good[j] = str_cnt(s+j,"good");
| ^~~~~~
main.cpp:41:32: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
41 | problem[j] = str_cnt(s+j,"problem");
| ^~~~~~~~~
ソースコード
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define SQR(X) ((X)*(X))
typedef long long ll;
typedef unsigned long long ull;
typedef long double lb;
/* ここからが本編 */
int str_cnt(char s1[],char s2[])
{
int cnt = 0;
int i,j;
for(i=0;s2[i];i++) {
if(s1[i] == s2[i]) cnt++;
}
return cnt;
}
int main(void)
{
int i,j,k;
int n,m;
char s[105];
int process[100];
int good[100];
int problem[100];
cin >> n;
rep(i,n) {
int cnt = 0;
cin >> s;
m = strlen(s);
for(j=0;j+3 <= m;j++) {
good[j] = str_cnt(s+j,"good");
}
for(j=0;j+7 <= m;j++) {
problem[j] = str_cnt(s+j,"problem");
}
for(j=0;j+3 <= m;j++) {
for(k = j+4; k+7 <= m; k++) {
if(good[j] + problem[k] > cnt) {
cnt = good[j] + problem[k];
}
}
}
process[i] = 11-cnt;
}
rep(i,n) {
cout << process[i] << endl;
}
return 0;
}