Show all threads Hide all threads Show all messages Hide all messages | if u have wa 19 | 👑TIMOFEY👑 | 1060. Flip Game | 4 Oct 2022 20:24 | 1 | i use clear binmask as in 1122, but in 1122 u can chek for answer your board by every change of bit, BUT in THIS problem, u need check board when you finish your changes with bits. Example u have bits 1101 and next is 1110, u firstly change 1111 and then 1110 (two iterations because we need to do this iterations on board) so if u do check on every that iteration its wa19 | if u have WA 8 | 👑TIMOFEY👑 | 1060. Flip Game | 4 Oct 2022 20:19 | 1 | | question to every one | Giorgi Javakhadze [Tsereteli SU] | 1060. Flip Game | 28 Dec 2016 03:21 | 7 | what is the answer for the following test bbbb wwwb wbwb wbbb my AC code shows that answer is 7, is that right? My AC program show answer 5 coordinates: 1:1, 1:2, 2:2, 2:3, 1:4, board becomes all black Edited by author 07.06.2011 00:10 yes that's what i'm talking about, my code fails on that test, but i got AC. i think it need to add test That to admins ;) What algo you're used? Your different submissions takes significand different time. Looks like random-based algo ) Edited by author 07.06.2011 00:26 i used recursion, those ones which execution time was higher had just deeper recursion My non-Accepted program gives 5. I have WA#11 | There exists O(2^8 * 8 ) solution !!!! | c_pp | 1060. Flip Game | 27 Dec 2016 22:40 | 1 | needn't all 2^16 search, divide it two part each 8 bit. | In case of WA#3 | nikitaevg | 1060. Flip Game | 19 Aug 2015 01:17 | 1 | | Test 10 PLZZZ | Grandmaster | 1060. Flip Game | 8 Jan 2015 21:42 | 1 | | WA on Test Case 11 | ultimatemaster | 1060. Flip Game | 10 Dec 2014 02:09 | 2 | Can anyone please provide test case #11? I am getting WA on that. try this one: wwww wwww bwwb bbbb answer: 2 | Help...TEST #9 | coco | 1060. Flip Game | 30 Apr 2012 17:01 | 1 | | answer 4; | Mehemmed Veliyev[Azerbaijan] | 1060. Flip Game | 26 Mar 2012 23:02 | 1 | answer 4; Mehemmed Veliyev[Azerbaijan] 26 Mar 2012 23:02 How answer is 4 . If we flip 16 pieces , then answer is 4 ? Is it true ? Thanks . | 0.001sec.... | starforever[V1] | 1060. Flip Game | 26 Mar 2012 23:01 | 5 | 2<<16 is less than million! 2<<16 is less than million! 2^16 is less than million/10! :)) Edited by author 27.12.2006 21:17My solution also takes 0.001 sec but I don't use full search. Carbon , do you only use procedure if you flip this piece ,you request to procedure ? Yes ? | Hint: this problem like 1122 | AterLux | 1060. Flip Game | 9 May 2011 21:00 | 1 | | WA#4! Can anybody help me?=) | Fessmax | 1060. Flip Game | 11 Nov 2010 16:45 | 2 | LOL! Stupid mistake! I forgot about Black side of this game=) I want to achieve only WHITE=) | if WA9 | yuanyuan | 1060. Flip Game | 31 Jul 2010 19:45 | 2 | if WA9 yuanyuan 7 May 2009 11:48 if WA9, try to check wwww wwww wwwb wwbb ans=1 My solution: program p1060; type frr=array[0..5,0..5] of boolean; var f:frr; ans:byte; procedure init; var i,j:byte; ch:char; begin fillchar(f,sizeof(f),true); for i:=1 to 4 do begin for j:=1 to 4 do begin read(ch); if ch='b' then f[i,j]:=false; end; readln; end; end; function check(f:frr):boolean; var b:boolean; i,j:byte; begin b:=f[1,1]; for i:=1 to 4 do for j:=1 to 4 do if f[i,j]<>b then exit(false); exit(true); end; function min(a,b:byte):byte; begin if a<b then exit(a) else exit(b); end; procedure find(f:frr;x,y,t:byte); begin if check(f) then begin ans:=min(ans,t); exit; end; if x>4 then exit; if y=4 then find(f,x+1,1,t) else find(f,x,y+1,t); f[x,y]:=not(f[x,y]); f[x-1,y]:=not(f[x-1,y]); f[x+1,y]:=not(f[x+1,y]); f[x,y-1]:=not(f[x,y-1]); f[x,y+1]:=not(f[x,y+1]); if y=4 then find(f,x+1,1,t+1) else find(f,x,y+1,t+1); end; procedure outit; begin if ans=17 then writeln('Impossible') else writeln(ans); end; begin init; ans:=17; find(f,1,1,0); outit; end. Edited by author 07.05.2009 11:48 Edited by author 07.05.2009 11:49 Yeah !! Thank you very much; I had tried many times. | WA #8 | Faeton (Kyiv - Mohyla Academy) | 1060. Flip Game | 29 Feb 2008 06:16 | 1 | WA #8 Faeton (Kyiv - Mohyla Academy) 29 Feb 2008 06:16 please, help me to find a bug, or give me some tests Here is my code. #include <iostream> #include <vector> #include <string> #include <math.h> #include <algorithm> #include <string.h> #include <stdio.h> #define MAX_VAL 100 using namespace std; int res = -1; vector<int> mem; void go(bool a[4][4],int cur) { long hex = 0,step = 1; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (a[i][j]==1) hex+=step; step*=2; } } if (hex==65535) { if (cur<res||res==-1) res = cur; return; } if (cur<mem[hex]) { mem[hex] = cur; int mov[4][2]; mov[0][0] = 1; mov[0][1] = 0; mov[1][0] = -1;mov[1][1] = 0; mov[2][0] = 0; mov[2][1] = 1; mov[3][0] = 0; mov[3][1] = -1; for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { bool next[4][4]; for (int w1 = 0; w1 < 4; w1++) for (int w2 = 0; w2 < 4; w2++) next[w1][w2] = a[w1][w2]; for (int k = 0; k < 4; k++) { int nx = x+mov[k][0],ny = y+mov[k][1]; if (nx>=0&&ny>=0&&nx<4&&ny<4) next[nx][ny] = 1-next[nx][ny];// flip } next[x][y] = 1-next[x][y]; go(next,cur+1); } } } } int main() { bool a[4][4],f = true; string s; for (int i = 0; i < 4; i++) { cin >> s; for (int j = 0; j < 4; j++) { if (s[j]=='w') a[i][j] = 0; else { a[i][j] = 1; f = false; } } } if (f) { cout << "0"; return 0; } for (long x = 0; x < 1<<16+1; x++) mem.push_back(MAX_VAL); go(a,0); if (res==-1) cout << "Impossible"; else cout << res; return 0; } | When it's 'Impossible' | LiuKe | 1060. Flip Game | 13 Jun 2007 15:53 | 2 | When should the program write('inpossible'); When you'll not be able to make the posision you need | How to deal with this problem? | pyh119_2007OnlineJudge | 1060. Flip Game | 14 Mar 2007 16:13 | 1 | | what is test 3? | rongyan | 1060. Flip Game | 9 Sep 2006 23:02 | 4 | I get wrong answer at test 3? why? this is my program: program gh; const x:array[1..4] of integer=(-1,0,1,0); y:array[1..4] of integer=(0,-1,0,1); var a,d,f,g,h,j,k,i,l,m,n:longint; s,z,c:string; procedure work(q:integer); var i,j,k,l:longint; v:string; begin if q=17 then begin if (pos('w',s)=0) and (g<m) then m:=g; end else begin v:=s; i:=((q-1) div 4)+1; j:=q-(i-1)*4; if s[q]='w' then s[q]:='b' else s[q]:='w'; for l:=1 to 4 do if (i+y[l]>0) and (i+y[l]<5) and (j+x[l]<5) and (j+x[l]>0) then if s[(i+y[l]-1)*4+j+x[l]]='w' then s[(i+y[l]-1)*4+j+x[l]]:='b' else s[(i+y[l]-1)*4+j+x[l]]:='w'; g:=g+1; work(q+1); g:=g-1; s:=v; work(q+1); end; end; begin s:=''; for i:=1 to 4 do begin readln(z); s:=s+z; end; g:=0; m:=1000000; work(1); if m=1000000 then writeln('Impossible') else writeln(m); end. Edited by author 06.09.2006 18:24 Try this! wwww wwww wwww wwww Your answer is 4, but the right answer is 0 Thank you vary much! I get ac. But how can you get the testdata? Can you give me some ural's testdata? This is my e-mail: liuxuelxg@163.com Thank you! I haven't got the testdata!)) That was just the first test I tried to check your program!)) | Hm... | Igor | 1060. Flip Game | 20 Feb 2006 21:05 | 4 | Hm... Igor 7 Jan 2002 13:57 Actually, i can't catch the idea of the problem... It seems to me that simple searching isn't good... but what then?? AC 0.092 and 122KB just full search | Come On!!!! 0.02sec 24KB !!!! Incredible (aidin_n7@hotmail.com) | Locomotive | 1060. Flip Game | 14 Jun 2005 16:15 | 7 | I did it in 0.08sec what other optimizations did you have that i dont have in my code? [code deleted] Edited by moderator 19.05.2020 22:17 if you notice that 4 blocks of first row and also first block of second row: XXXX X... .... .... will force other blocks choosing...and these have 32ways only! after selecting True or False for choose (and reverse) these blocks, first block of first row will have just one side which never will change by others: X*** *OOO OOOO OOOO {O never change side of X} and all of '*'`s force the blocks under them such as E forces D XE** *DOO OOOO OOOO I mean that if E has same colour as X then D shouldn`t choose to reverse (because after it side of E will change and it will be agains the X and never change and....) and so on... so should calculate just first 5 blocks and it is O(32)!!! Sincerely Aidin_n7@hotmail.com I cannot understand what you have said. Which 5 blocks do you choose? Can you explain it to me? Have you got AC? Could you public your program?(If you don't want to talk much)(PASCAL will be better) Thank you very much. I encode the table to LongInt var (You may use Word if you want) And then I use BFS, here is my code: And I got 0.031s [code deleted] Edited by moderator 19.05.2020 22:18 | 0.097 sec ^_^ | Erwin | 1060. Flip Game | 10 Aug 2004 19:56 | 1 | |
|
|