結果
問題 | No.517 壊れたアクセサリー |
ユーザー |
|
提出日時 | 2017-05-28 21:49:24 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 850 bytes |
コンパイル時間 | 307 ms |
コンパイル使用メモリ | 22,272 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-21 15:23:23 |
合計ジャッジ時間 | 1,812 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 6 WA * 4 RE * 5 |
コンパイルメッセージ
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); | ^~~~~~~~~~~~~
ソースコード
#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){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]){k+=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;}}}}}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;}