結果
| 問題 | 
                            No.345 最小チワワ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             1EP451
                         | 
                    
| 提出日時 | 2016-02-28 21:41:10 | 
| 言語 | C90  (gcc 12.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 484 bytes | 
| コンパイル時間 | 550 ms | 
| コンパイル使用メモリ | 20,736 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-24 12:08:58 | 
| 合計ジャッジ時間 | 1,349 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 WA * 4 | 
コンパイルメッセージ
main.c: In function ‘main’:
main.c:13:17: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[100]’ [-Wformat=]
   13 |         scanf("%s",&S);
      |                ~^  ~~
      |                 |  |
      |                 |  char (*)[100]
      |                 char *
main.c:13:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         scanf("%s",&S);
      |         ^~~~~~~~~~~~~~
            
            ソースコード
#include<stdio.h>
#define N 100
char S[N];
int s_check[N]={0};
int ans=N+1;
int return_flg=0;
int main (void){
	int i,j;
	scanf("%s",&S);
	for(i=0;i<N;i++){
		if(S[i]=='c') s_check[i]=1;
		else if(S[i]=='w') s_check[i]=2;
	}
	for(i=0;i<N;i++){
		if(s_check[i]==1){
			for(j=i+1;j<N;j++){
				if(s_check[j]==2) return_flg++;
				if(return_flg>1){
					if(ans>(j-i+1)) ans=j-i+1;
					return_flg=0;
					break;	
				}
			}
			
		}
	}
	if(ans==N+1) ans=-1;
	printf("%d",ans);
}
            
            
            
        
            
1EP451