From 116210761a32ee1e114a9ef9349070c33ecbc355 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Sat, 30 May 2020 22:43:54 +0000 Subject: [PATCH] Latest version --- F-70.out | 0 G-70.out | 1 - cowntact.txt | 16 +++++++++------- output | Bin 308 -> 1927 bytes problems/55-G.txt | Bin 0 -> 2106 bytes A-70.out => problems/A-70.out | Bin B-70.out => problems/B-70.out | 0 B.out => problems/B.out | 0 C-70.out => problems/C-70.out | 0 C.out => problems/C.out | 0 D-70.out => problems/D-70.out | 0 E-70.out => problems/E-70.out | 0 E.out => problems/E.out | 0 problems/F-70.out | 1 + problems/F-70.txt | 5 +++++ problems/G-70.out | 1 + G.out => problems/G.out | 0 H-70.out => problems/H-70.out | 0 src/encode.cpp | 9 +++++++++ 19 files changed, 25 insertions(+), 8 deletions(-) delete mode 100644 F-70.out delete mode 100644 G-70.out create mode 100644 problems/55-G.txt rename A-70.out => problems/A-70.out (100%) rename B-70.out => problems/B-70.out (100%) rename B.out => problems/B.out (100%) rename C-70.out => problems/C-70.out (100%) rename C.out => problems/C.out (100%) rename D-70.out => problems/D-70.out (100%) rename E-70.out => problems/E-70.out (100%) rename E.out => problems/E.out (100%) create mode 100644 problems/F-70.out create mode 100644 problems/F-70.txt create mode 100644 problems/G-70.out rename G.out => problems/G.out (100%) rename H-70.out => problems/H-70.out (100%) diff --git a/F-70.out b/F-70.out deleted file mode 100644 index e69de29..0000000 diff --git a/G-70.out b/G-70.out deleted file mode 100644 index 05d0665..0000000 --- a/G-70.out +++ /dev/null @@ -1 +0,0 @@ -blgy lab ucf rcntly hvng prblms trnsmttng gntc sqncs btwn cmptrs.nfrtntly,crrnt systm rprsnts gntc sqncs strng chrctrs,'a','c','g','t'.order speed data trnsfrs tskd cmprssng data.lckly,prfssr dvsd easy,gave task ctlly mplmntng.cnsdr each lttrs nmbr bs-4,'a' = 0,'c' = 1,'g' = 2,'t' = 3,gntc sqnc nq bs-10 rprsnttn.needs mplmnt prgrm cnvrt strng dscrbng gntc sqnc bs-10 nmbr,vc-vrs,given bs-10 nmbr,opt crrspndng gntc sqnc.prblm,given gntc sqnc,opt crrspndng bs-10 nmbr.lkws,given nmbr bs-10,opt crrspndng gntc sqnc.ipf line ipt cntn pstv ntgr,q,rprsntng nmbr sqncs cnvrt.next q lines cntn thr ntgr,n,1<=n<=2^{30}-1,rprsnts bs-10 nmbr,grntd ldng zrs,gntc sqnc,rprsntd strng chrctrs 'a','c','g' nd/r 't',grntd ldng,btwn 1,15 chrctrs lngth.opf each sqnc,opt hdr sqnc #j,j rprsnts sqnc being prcssd,bgnnng 1.fllwng hdr,opt thr crrspndng gntc sqnc ntgr given,crrspndng bs-10 nmbr gntc sqnc.opt each sqnc each own opt line diff --git a/cowntact.txt b/cowntact.txt index 7214c55..0032fdf 100644 --- a/cowntact.txt +++ b/cowntact.txt @@ -1,21 +1,23 @@ -Farmer John is planning to build N (1≤N≤105) farms that will be connected by N−1 roads, forming a tree. Typically, whenever one of his farms is having an issue he is not told the specific farm that is having an issue. Instead, he is told that one of the farms along the path from some farm A to another farm B is having an issue. This is often confusing for Farmer John, as he usually drives offroad tractors and isn't familiar with the road system. +Farmer John is planning to build N (1<=N<=105) farms that will be connected by N-1 roads, forming a tree. Typically, whenever one of his farms is having an issue he is not told the specific farm that is having an issue. Instead, he is told that one of the farms along the path from some farm A to another farm B is having an issue. This is often confusing for Farmer John, as he usually drives offroad tractors and isn't familiar with the road system. Farmer John considers the location of a farm to be a 2D point. He would prefer to be told that there is a problem in one of the farms in a specified axis-aligned rectangular box. This way Farmer John can decide for himself how to navigate between the farms. Bessie told him that this is a little too ambitious, so he will be satisfied if he is notified with at most two axis-aligned rectangular boxes whose intersection (of farms) is empty and whose union is exactly the farms along the path from A to B. You must help Farmer John determine where he should build his farms such that this condition is satisfied. This is an interactive problem, you will not be using standard (or file) I/O. Solutions that use standard (or file) I/O will be disqualified. However, you ARE ALLOWED to use global and static variables. You must implement the following functions to help Farmer John: -void addRoad(int A, int B): processes a road between farms A and B (0≤A,B≤N−1). +void addRoad(int A, int B): processes a road between farms A and B (0<=A,B<=N-1). void buildFarms(): determines where Farmer John should build all his farms. void notifyFJ(int A, int B): notifies Farmer John with either one or two boxes that satisfy the aforementioned conditions. -Your implementation of the above functions will be able to call the functions given below. You may assume that notifyFJ will be called Q times (1≤Q≤105). +Your implementation of the above functions will be able to call the functions given below. You may assume that notifyFJ will be called Q times (1<=Q<=105). int getN(): gets the value of N. int getQ(): gets the value of Q. -void setFarmLocation(int ID, int X, int Y): determines that Farmer John should build farm ID (0≤ID≤N−1) at location (X,Y) where (1≤X,Y≤N). Should only be called from buildFarms. -void addBox(int X1, int Y1, int X2, int Y2): adds a box to notify Farmer John where (1≤X1≤X2≤N) and (1≤Y1≤Y2≤N). Should only be called from notifyFJ. -The interactive protocol works as follows. First, addRoad will be called N−1 times, to inform your program of the road system. Then, buildFarms will be called and you must determine where Farmer John should build each farm and call setFarmLocation for every farm accordingly. Finally, there will be Q calls to notifyFJ where you must make either one or two calls to addBox to notify Farmer John. +void setFarmLocation(int ID, int X, int Y): determines that Farmer John should build farm ID (0<=ID<=N-1) at location (X,Y) where (1<=X,Y<=N). Should only be called from buildFarms. +void addBox(int X1, int Y1, int X2, int Y2): adds a box to notify Farmer John where (1<=X1<=X2<=N) and (1<=Y1<=Y2<=N). Should only be called from notifyFJ. +The interactive protocol works as follows. First, addRoad will be called N-1 times, to inform your program of the road system. Then, buildFarms will be called and you must determine where Farmer John should build each farm and call setFarmLocation for every farm accordingly. Finally, there will be Q calls to notifyFJ where you must make either one or two calls to addBox to notify Farmer John. It is guaranteed there is always a valid way to notify Farmer John using either one or two boxes. The memory limit for this problem is set to 512MB, above the usual 256MB limit. - +$$$$$$$$$$ +.............. +,,,,.,.,.,.,.,:":ef[]wlf[wepk[]] For a C++ solution, use this template: #include "grader.h" diff --git a/output b/output index c98c1a5b1a5dffe411868a35f6b71d6427f29cb5..83147e4e171bf4c3b1e73cd589de22ed02145223 100644 GIT binary patch literal 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c;Ge_Sg z<{%H)L8G*Z2$lgcrH)7v0zrq?A*9r`qq1oT>^A9uCY%)uWknzfvu_>VyXD^bi6P(l zA6>fS&YWR=_k_BG6e-!XRFfeF#v#Zh{>;6@r{)j-2!l`Q94)*RZ+$o32Fo{_Kf=bC z$pw~q#MUj71IMpFXUsHJc4dZhzqD~N*Kd3Zc4oC5Cyx{Jomt`ZNvCD}6+yHoLSkYH zDgqosWk=w+_;PJam;UR4Kp^nr^gkA4Or}}AMDr_u5zkzn4?{fAh*5QZC9|(;z~?z6 YvlNV(qxV6Jdtpr|t(dR|Cxqtz03o^($^ZZW literal 308 zcmV-40n7fXPWQU@&0XE>?hV^rk7rG<>hS1V-1Tecn_SDr4_sze1-tsOt@AeAs-9Lh^{*OQZ^Hc=RrJtBX^8mc7?B$ex*Rj^D##8lA4zq?|gOmzOVG~uGXx^>gMNB>EV@rVyb^wCK}hQ#!Y96OAqh*0uEm%uqgSc zOkxg|y<9Kc8)_IZT|IAprJtA$^PD$x`zwUuGX#UH?4^@(6<=j9&2*f~Uar%0O5dL) GS8)Pf#-$Aa diff --git a/problems/55-G.txt b/problems/55-G.txt new file mode 100644 index 0000000000000000000000000000000000000000..db997e80312b9887d9f36e091eea42d98ec2d816 GIT binary patch literal 2106 zcmZuxdrTBZ7;n>B4Yg`xO>0q^YL!%%lRG$65RA5^jS5srv52p|-Mzh)z1d}E?#=@_ z6JPj3jix>tt<|;?f(9!-00E;YYJF6LsBIOSB1)u4M9&JS?aUqm8vodAX6E~T-}n1{ zzZsh_BiJfo5}|d?*(x&`+ix2{kDY zXh@V0AR55BB#FSK1Cb}Z(TE*k;MH8TVYd`$mEd#{cogDb?I4UPI*T@`LONw**AR>6 z=!YmFJH`lzZY%;G0*S|7;NiWjlBfaVP%vk65#W%3%-~ra!sB$KTcT1lr>;67Q$iso z8ijd9q-j(`#co6k5Q~W73J#V-91@m*N+?TUaEDGC0+gQ(hedMOMWc*lssM-u;Y*Yrn2iuM$SMvkD{tT zfNn%O$01??*(fc(TM3%Ycfhm0IVz-E2y@ek$%>mb^unP|0G&S8p-5pmePS{!)S1w^ z&uK5j2S~6gCNrHs5Gtb_WNEx@q(l#YZXFu#+Kv2T+U+O>`Zj782SLr7P~ ztuveKs_LOD3SmGosb1j)qbSo482(}8yP~=rV1#uIml@@SZUJ_vVxV~&9X6y_5d)1r zMl6yUz=U-LL;yjM2{1=Rjj;k*mI-^fbo!te6sa)AL11O!jM%^;f-^^2%$9LMNl1|u z$g4n=m~7F&Y#nC_`c$KDjD#_Lm7ed9F-HY`B_TngPoL0ntY|PASgodTi`6_lXujwC zoLPT1raq0nTH9Xp*k9dtsPuu~kyg05rY^p3;n~4QX1{afpf{zad99~B%kQf_SRcD% z&ft5=H$DE6GkHCy?JwRqaYCCpqcA?UM?!J3pr4#KJ9N0ayuaiTvUk=Gn0WVqTzsvx z=(b*TY3YLvD}5O?kCNq`jc`RpVzuJ=lax& z$|=D`vAd7v4r%_ZB=yduf98kZzWhPiYOP(>T)((d`0U`=+n+t|6f+c?<{?ELN8BR|KMDI`JG?Osw&EB z8k+Bw^gHsyp|XLyhFm{vkrGRb;_lY%Q+%hCalf~%TA5jJX-Cz=;+Q8NSJ%N-C1G96 z(H)tY*HagcTGCga>+pWQzF=C&7i4DQ+54AM8>(h)t=zKr!m?{I*RPz2Uo`8^Q`(~bB;%;6}Cot#T6FqOtNUIon+Iy{i zt3|o+EWhZYe-+5HpDInv|6}~@*RIG}1!;Km`hiz!HpMmg3d%aADhY0B_;zm4|NJ9p AMF0Q* literal 0 HcmV?d00001 diff --git a/A-70.out b/problems/A-70.out similarity index 100% rename from A-70.out rename to problems/A-70.out diff --git a/B-70.out b/problems/B-70.out similarity index 100% rename from B-70.out rename to problems/B-70.out diff --git a/B.out b/problems/B.out similarity index 100% rename from B.out rename to problems/B.out diff --git a/C-70.out b/problems/C-70.out similarity index 100% rename from C-70.out rename to problems/C-70.out diff --git a/C.out b/problems/C.out similarity index 100% rename from C.out rename to problems/C.out diff --git a/D-70.out b/problems/D-70.out similarity index 100% rename from D-70.out rename to problems/D-70.out diff --git a/E-70.out b/problems/E-70.out similarity index 100% rename from E-70.out rename to problems/E-70.out diff --git a/E.out b/problems/E.out similarity index 100% rename from E.out rename to problems/E.out diff --git a/problems/F-70.out b/problems/F-70.out new file mode 100644 index 0000000..2c03925 --- /dev/null +++ b/problems/F-70.out @@ -0,0 +1 @@ +fj plcd n boxes vrtcs rtd tree,nmbrd 1 n,1<=n<=10000.ntlly,each box cntnd xctly one mrbl.nfrtntly,mschvs elsie moved mrbls rnd,boxes empty cntn one mrbl,total nmbr mrbls still n.bss dcdd help fj mvng mrbls such each box cntns xctly one mrbl again.ccmplshd sqnc moves,each move cnssts mvng one mrbl box djcnt vrtx.mnmm nmbr moves rqrd bss chv goal.ipf each case strts nmbr n fllwd n lines.each line cntns least three nmbrs,1<=v<=n,nmbr vrtx.vrtcs nmbrd 1 n,given ncrsng order ipt.0<=m<=n,nmbr mrbls rgnlly plcd vrtx v.0<=d<=n-1, nmbr chldrn v.same line,fllw d dstnct vrtx nmbrs gvng dntts chldrn v.opf each case,opt smllst nmbr moves mrbls rsltng one mrbl each vrtx tree \ No newline at end of file diff --git a/problems/F-70.txt b/problems/F-70.txt new file mode 100644 index 0000000..69de629 --- /dev/null +++ b/problems/F-70.txt @@ -0,0 +1,5 @@ +fj plcd n boxes vrtcs rtd tree,nmbrd 1 n,1<=n<=10000.ntlly,each box cntnd xctly one mrbl.nfrtntly,mschvs elsie moved mrbls rnd,boxes empty cntn one mrbl,total nmbr mrbls still n.bss dcdd help fj mvng mrbls such each box cntns xctly one mrbl again.ccmplshd sqnc moves,each move cnssts mvng one mrbl box djcnt vrtx.mnmm nmbr moves rqrd bss chv goal.ipf each case strts nmbr n fllwd n lines.each line cntns least three nmbrs,1<=v<=n,nmbr vrtx.vrtcs nmbrd 1 n,given ncrsng order ipt.0<=m<=n,nmbr mrbls rgnlly plcd vrtx v.0<=d<=n-1, nmbr chldrn v.same line,fllw d dstnct vrtx nmbrs gvng dntts chldrn v.opf each case,opt smllst nmbr moves mrbls rsltng one mrbl each vrtx tree +Original length: 1103 +Compressed length: 330 +Percent compression: 70.0816% +fpv:n]_ӻ<-o{w5jm^,>)wCgVJ8-3|+'{;C~nqus'3OơY\}7t38zq]oz.Up7sb4vu=b Ѝ^?בqm\ׇd$|OĒ'Kqhqh6Lq{ym\wC(Nk]ϼ[,W"w3GM{A:J[ji~gwѸ o"8FsCSXf{c =0 && c <128); +} +void stripUnicode(string & str) +{ + str.erase(remove_if(str.begin(),str.end(), invalidChar), str.end()); +} string huffmancompress(string s) { @@ -396,6 +404,7 @@ int main(int argc, char *argv[]) { input+=line; input+='\n'; } + stripUnicode(input); initsize=input.length()-1;//remove last newline for(char& x:input)