結果

問題 No.517 壊れたアクセサリー
ユーザー YamyukiYamyuki
提出日時 2017-05-28 22:04:37
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 872 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 22,680 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 14:12:21
合計ジャッジ時間 1,366 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,348 KB
testcase_01 AC 0 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 0 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 0 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:3:5: warning: conflicting types for built-in function ‘strlen’; expected ‘long unsigned int(const char *)’ [-Wbuiltin-declaration-mismatch]
    3 | int strlen(char *s){
      |     ^~~~~~
main.c:2:1: note: ‘strlen’ is declared in header ‘<string.h>’
    1 | #include<stdio.h>
  +++ |+#include <string.h>
    2 | 
main.c: In function ‘main’:
main.c:12:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d",&n);
      |         ^~~~~~~~~~~~~~
main.c:14:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                 scanf("%s",a[i]);
      |                 ^~~~~~~~~~~~~~~~
main.c:23:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |         scanf("%d",&m);
      |         ^~~~~~~~~~~~~~
main.c:25:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |                 scanf("%s",b);
      |                 ^~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

int strlen(char *s){
	int i=0;
	while(s[i]!='\0'){i++;}
	return i;
}

int main(int argc, char const *argv[]){
	int n,m,i,j,c[26],d,e=-1,k,l,len=0;
	char a[26][27],b[27];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",a[i]);
		c[i]=strlen(a[i]);
		len+=c[i];
		getchar();
	}
	if(n==1){
		printf("%s\n",a[0]);
		return 0;
	}
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%s",b);
		getchar();
		d=strlen(b);
		if(d>1){
			e=-1;
			for(j=0;j<d;j++){
				for(k=0;k<n;k++){
					for(l=0;l<c[k];l++){
						if(a[k][l]==b[j]) break;
					}
					if(l<c[k]){
						j+=c[k]-l-1;
						if(e!=-1){
							for(l=0;l<=c[k];l++){
								a[e][c[e]+l]=a[k][l];
							}
							c[e]+=c[k];
							c[k]=0;
						}else e=k;
						break;
					}
				}
			}
		}
	}
	for(i=0;i<n;i++){
		if(c[i]==len) break;
	}
	if(i==n) printf("-1\n");
	else printf("%s\n",a[i]);
	return 0;
}
0