Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | What if I tell you that you don't need to find words placements | FatalityNT | 1164. Fillword | 25 мар 2021 01:13 | 1 | You can just count letters Edited by author 25.03.2021 01:13 | I have AC. I am interested in another method of solution. | Mahilewets | 1164. Fillword | 15 июл 2017 21:56 | 3 | http://ideone.com/06yGHW Maybe someone could improve that solution and get AC with it. Current status of that code is WA#8. I think it is quite boring and tedious to upgrade it to AC. Maybe you can see how to upgrade it with small effort. Incredible, my code contained a mistake. Mistake was that I wrote not q=go[q]. next [ch], but simply go[q]. next [ch]. Strange enough, compiler didn't warned me about unused variable. So, the problem can be solved using DFS+Trie in 15 ms. Edited by author 15.07.2017 21:56 Edited by author 15.07.2017 21:56 | Why WA?Here is my program can anybody help me :( | mariam kupatadze | 1164. Fillword | 6 май 2017 22:33 | 2 | Here is my program,I have taken WA on the test of 2, I think it is correct,please tell me what is wrong,please if you can.. program fillword; var a:array[1..10] of string; b,k:array[1..100] of string; i,j,n,m,p,t:integer; ch:char; l,r:string; begin read(n,m,p); readln; for i:=1 to n do readln(a[i]); for j:=1 to p do readln(b[j]); for i:=1 to p do for j:=1 to n do if b[i]=a[j] then begin t:=t+1; k[t]:=b[i]; break; end; for i:=1 to t do begin r:=''; l:=k[i]; for ch:='A' to 'Z' do for j:=1 to m do if ch=l[j] then r:=r+ch; writeln(r); end; end. 9 years later... >for i:=1 to p do > for j:=1 to n do I suppose, it shouldn't be to p... | To admins | Timur Sitdikov (MSU TB) | 1164. Fillword | 11 дек 2014 19:40 | 2 | To admins Timur Sitdikov (MSU TB) 22 апр 2011 21:20 It's not clear if each word must be found in the grid only once. Maybe task should be edited. Agreed! The description should be rewritten. | will any body help me? I am OLE | mahbubul | 1164. Fillword | 10 дек 2011 12:05 | 2 | I am Output Limit Exceed. my source is in C++. Here this is: #include<iostream.h> #include<string.h> main() { int len,temp,i; int n,m,j,p; char ch[12][12],word[15]; char letter; long int array[30]; for(i=0;i<27;i++) array[i]=0; cin>>n>>m>>p; for(i=1;i<=n;i++) cin>>ch[i]; for(i=1;i<=p;i++){ cin>>word; len=strlen(word); for(int k=0;k<len;k++){ temp=word[k]; array[temp-64]--; }} for(i=1;i<=n;i++) for(j=0;j<m;j++){ temp=ch[i][j]; array[temp-64]++; } for(i=1;i<27;i++){ temp=array[i]; letter=i+64; while(temp!=0){ cout<<letter; temp--; }} cout<<endl; return 0; } make temp!=0 - temp > 0; and some other changes, but it gets WA11 Edited by author 10.12.2011 12:10 | Some hint | Ladik Artem | 1164. Fillword | 7 ноя 2010 02:30 | 1 | I use one array of int. It size is 256. Good luck!!! | HELP PLEASE! WA#8! | BlackShark | 1164. Fillword | 28 апр 2009 11:48 | 3 | var a:array[0..25] of integer; i,j,n,m,p:integer; ch:char; begin readln(m,n,p); for i:=1 to n do begin for j:=1 to m do begin read(ch); inc(a[ord(ch)-ord('A')]); end; readln; end; for i:=1 to p do begin while not eoln do begin read(ch); dec(a[ord(ch)-ord('A')]); end; readln; end; for i:=0 to 25 do if a[i]>0 then for j:=1 to a[i] do write(chr(ord('A')+i)); end. var a:array[1..26]of integer; n,m,i,j,p:integer; k:char; o:string; begin readln(n,m,p); for n:=1 to n do begin for m:=1 to m do begin read(k); i:=ord(k)-64; inc(a[i]); end; readln; end; for p:=1 to p do begin readln(o); for i:=1 to length(o) do begin j:=ord(o[i])-64; dec(a[j]); end; end; for i:=1 to 26 do if a[i]<>0 then begin for j:=1 to a[i] do write(chr(i+64)); end; end. | WA#8 | mapron | 1164. Fillword | 3 окт 2008 14:23 | 2 | WA#8 mapron 26 сен 2008 19:50 //--------------------------------------------------------------------------- ... scanf("%d %d %d\n",&M,&N,&P); ... I have used a simple algo, but got WA... maybe format mistake? Edited by author 03.10.2008 14:24 Yes, i had misplaced M and N parametres... be careful! | Can anyone explain me this problem in Russian??? | [SSAU_#617]snipious aka Pimenov Sergey Nikolaevich | 1164. Fillword | 8 янв 2007 12:48 | 4 | Please send me the meaning of problem to snipious@mail.ru!!! I've sent a message for you!) Thank you very much!!! Edited by author 08.01.2007 12:18 | Excuse me! who can help me to translate it into Chinese,thanks a lot!! :) | sgzll | 1164. Fillword | 6 июл 2006 09:45 | 5 | 1164 Fillword 时间限制 1秒 内存限制 1000K Alex喜欢解决fillword问题。fillword是一个规则非常简单的文字游戏。作 者给出一个矩形表格(N行M列)和P个单词,然后在表格内填入字母(每格一 个)。那么,每个单词都能在表格里找到,条件如下 · 每一个格只属于一个单词 · 每一个格只能用一次 对于某一单词W(我们认为它的长度为K),如果你能找到一个关于(x1,y1) ,(x2,y2),…,(xk,yk)序列符合下列条件,那么它可以在表格中找到: ·(xi,yi)和(xi+1,yi+1)相邻,即|xi-xi+1| + |yi-yi+1| = 1其中i = 1, 2, ... , k-1 ·W[i] 出现在与之相对应的格(xi, yi) 现在的任务是在表格内找出所有单词。之后,你会发现一些字母没有被用上 (它们不属于任何一个已经找到的单词)。你把它们组成一个神秘的单词, 你就可以赢取一个大奖。 你的任务是帮助Alex去解决fillword问题。你只要找出哪些字母会在找出所有单 词后没有用上。而最重要的任务—把它们组成一个神秘的单词—我们仍然留 给Alex。 输入 第一行包含3个整数—N, M (2 <= M, N <= 10) 和P (P <= 100)。接下 来的N行每行包含M个格,描述一个表格。下面的P行是要在表格中找出的单词 。 Fillword通常会有一个最简的解决方案。所有在Fillword中出现的都是 大写英文字母。 输出 输出组成神秘单词的字母。字母应该按字典顺序排列。 Sample Input 3 3 2 EBG GEE EGE BEG GEE Sample Output EEG give me a link to e chinese teach-yourself book :) Edited by author 02.05.2005 16:34 Edited by author 02.05.2005 16:34 Thank you for enjoying our language!!!:) | Can a single word be used for more that once?And does any of the word finding result(No matter leave how many letters,but until no word can be found) acceptable? | Huang Yizheng | 1164. Fillword | 2 май 2005 16:51 | 2 | | Is there any trick in test #10 | akademi | 1164. Fillword | 12 мар 2005 21:07 | 2 | I know I can calculate the anwser directly,but I used DFS algorithm at first.I think it can solve this problem too,but I got WA on test #10,who can tell me WHY? thx. My code: /* ural1164 */ #include<iostream> #include<string.h> using namespace std; const way[4][2]={{1,0},{0,-1},{-1,0},{0,1}}; int m,n,p; char map[15][15]; bool check[15][15]; bool flag,fflag; char word[150][300]; void init() { int i,j; cin>>n>>m>>p; for(i=1;i<=n;i++) for(j=1;j<=m;j++) cin>>map[i][j]; for(i=1;i<=p;i++) cin>>word[i]; fflag=false; } void find(int x,int y,int d,int l) { int i,xx,yy; if(flag) return; check[x][y]=true; if(l==strlen(word[d])+1) { flag=true; return; } for(i=0;i<=3;i++) { xx=x+way[i][0]; yy=y+way[i][1]; if(map[xx][yy]==word[d][l-1] && !check[xx][yy]) find(xx,yy,d,l+1); } if(flag) return; check[x][y]=false; return; } void out() { int i,j,l; char w; char ans[300],*p; p=ans; for(i=1;i<=n;i++) for(j=1;j<=m;j++) if(!check[i][j]) *(p++)=map[i][j]; *p='\0'; l=strlen(ans); for(i=l-1;i>=0;i--) for(j=0;j<=i-1;j++) if(ans[j]>ans[j+1]) { w=ans[j]; ans[j]=ans[j+1]; ans[j+1]=w; } cout<<ans<<endl; } void search(int x) { bool check1[15][15]; int i,j; if(x==p+1) { out(); fflag=true; } if(fflag) return; for(i=1;i<=n;i++) for(j=1;j<=m;j++) if(map[i][j]==word[x][0] && !check[i][j]) { memmove(check1,check,sizeof(check)); flag=false; find(i,j,x,2); if(flag) search(x+1); memmove(check,check1,sizeof(check1)); } } void work() { memset(check,false,sizeof(check)); search(1); } int main() { init(); work(); return 0; } I think there is no trick in this test. There is more simple solution (only 15 strings code)... Try to find it! | How to solve this kind of problems???(puzzles) | Miguel Angel | 1164. Fillword | 12 окт 2004 07:27 | 5 | I use a recursive algorithm, but get TIME LIMIT EXCED. I think this problem is very easy :) U don't need to find out the sequence of cells of each word if a[x] is the number of letter x on the grid b[x] is the number of letter x in all the words then the number of letter x in the hidden word is a[x] - b[x] Thanks a lot, it helps me to solve this problem without my stupid idea... | Why I got WA?? Please HELP!!! (in C) | 55555 | 1164. Fillword | 30 июл 2003 14:50 | 1 | #include <stdio.h> void main() { long n,m,p,i,j,a[27]={0}; char c; scanf("%ld %ld %ld\n",&n,&m,&p); for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { scanf("%c",&c); a[c-64]++; } } for(i=1;i<=p;i++) { zy: scanf("%c",&c); if(c=='\n') goto zy; else a[c-64]--; while(c>='A'&&c<='Z') { scanf("%c",&c); a[c-64]--; } } for(i=1;i<=26;i++) for(j=1;j<=a[i];j++) printf("%c",i+64); } | Why I got WA!!!HelpHelpHelp!This is my grogram. | Superthinker | 1164. Fillword | 24 июл 2003 06:08 | 2 | Why I got WA!!!HelpHelpHelp!This is my grogram: var Save : array ['A' .. 'Z'] of longint; n, m, p, i, j : longint; c : char; begin fillchar (Save, sizeof (Save), 0); readln (n, m, p); for i := 1 to n do begin for j := 1 to m do begin read (c); Save [c] := Save [c] + 1; end; readln; end; for i := 1 to p do begin for j := 1 to m do begin read (c); Save [c] := Save [c] - 1; end; readln; end; for c := 'A' to 'Z' do for i := 1 to Save [c] do write (c); end. var Save : array ['A' .. 'Z'] of longint; n, m, p, i, j : longint; c : char; begin fillchar (Save, sizeof (Save), 0); readln (n, m, p); for i := 1 to n do begin for j := 1 to m do begin read (c); Save [c] := Save [c] + 1; end; readln; end; for i := 1 to p do begin read (c); while not (c in ['A' .. 'Z']) do read (c); while c in ['A' .. 'Z'] do begin Save [c] := Save [c] - 1; read (c); end; end; for c := 'A' to 'Z' do for i := 1 to Save [c] do write (c); end. | I have got WA.What is wrong with my program? | Tony | 1164. Fillword | 7 окт 2002 15:16 | 1 | const max=10; maxp=100; var g:array[1..max,1..max]of char; lt:array[1..max,1..max]of byte; pri:array['A'..'Z']of byte; m,n,p,mark:integer; s:string; procedure find_work(t,x,y:integer); var i,j:integer; begin if t>m then begin mark:=1;exit;end; for i:=1 to n do for j:=1to m do if(s[t]=g[i,j])and((abs(i-x)+abs(j-y)=1)or((x=0)and(y=0))) then begin inc(lt[i,j]); find_work(t+1,i,j); if mark=1 then exit; dec(lt[i,j]); end; end; procedure init_work; var i,j:integer; begin fillchar(g,sizeof(g),0); fillchar(lt,sizeof(lt),0); fillchar(pri,sizeof(pri),0); readln(n,m,p); for i:=1 to n do begin for j:=1 to m do read(g[i,j]); readln; end; for i:=1 to p do begin readln(s); mark:=0; find_work(1,0,0); end; end; procedure outit_work; var ch:char; i,j:integer; begin for i:=1 to n do for j:=1 to m do if lt[i,j]=0 then inc(pri[g [i,j]]); for ch:='A' to 'Z' do for i:=1 to pri[ch] do write(ch); end; begin init_work; outit_work; end. | Why WA?! | Avanesov | 1164. Fillword | 22 мар 2002 20:18 | 3 | Maybe I did not understand my task right?! Here is my program: program p1164; var n,m,p : integer; a : array['A'..'Z'] of integer; i : integer; j : integer; ch : char; begin fillchar(a,sizeof(a),0); readln(n,m,p); for i:=1 to n do begin for j:=1 to m-1 do begin read(ch); inc(a[ch]); end; readln(ch); inc(a[ch]); end; for i:=1 to p do begin for j:=1 to m-1 do begin read(ch); dec(a[ch]); end; readln(ch); dec(a[ch]); end; for ch:='A' to 'Z' do begin for i:=1 to a[ch] do Write(ch); end; writeln; end. > Maybe I did not understand my task right?! > Here is my program: > > program p1164; > var > n,m,p : integer; > a : array['A'..'Z'] of integer; > i : integer; > j : integer; > ch : char; > begin > fillchar(a,sizeof(a),0); > readln(n,m,p); > for i:=1 to n do > begin > for j:=1 to m-1 do > begin > read(ch); > inc(a[ch]); > end; > readln(ch); > inc(a[ch]); > end; > for i:=1 to p do > begin > for j:=1 to m-1 do > begin > read(ch); > dec(a[ch]); > end; > readln(ch); > dec(a[ch]); > end; > > for ch:='A' to 'Z' do > begin > for i:=1 to a[ch] do Write(ch); > end; > writeln; > end. | Ambiguous task... I think it should be cleared up | Grigory Makeev | 1164. Fillword | 23 янв 2002 21:50 | 2 | | Sorry,I made some glaring errors in my program,so...But now it's accepted. | Huang Yizheng | 1164. Fillword | 11 дек 2001 07:09 | 1 | | What does "find all the words on the grid" mean?It means all P words must be found,or all the words hiden on the grid must be found? | Huang Yizheng | 1164. Fillword | 10 дек 2001 17:33 | 1 | |
|
|