Latest version

This commit is contained in:
Anthony Wang 2020-05-30 22:43:54 +00:00 committed by repl.it user
parent 7aa23b3623
commit 116210761a
19 changed files with 25 additions and 8 deletions

View file

View file

@ -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

View file

@ -1,21 +1,23 @@
Farmer John is planning to build N (1≤N≤105) farms that will be connected by N1 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≤N1).
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≤N1) 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 N1 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"

BIN
output

Binary file not shown.

BIN
problems/55-G.txt Normal file

Binary file not shown.

1
problems/F-70.out Normal file
View file

@ -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

5
problems/F-70.txt Normal file
View file

@ -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%
ªf<EFBFBD>îp÷æõøvÕé:þ½n]_ÝðÏÓ»<»ê÷äç-o{ãw5¨jØùŽm^¼û,>É)îwCg¹VJ¹Ò8-3ð|+î´'{;‡Cÿê~î†nôúq©ÞÆu½ÿsé«3OÁÆ¡Y×õ\}7t3ô8zý…·q]ùžo<C5BE>ëz.Upß÷7sb4—v·—Çu=—b ÎÁÝÐ<C39D>^?×úqám\ׇd$|OÄ'ŒK§qhÀÁqh6úLÍq{yám\×wC·(N¯k¥]Ïϼç[ãÐ,W"w3G°MÈ{A:ÏÁJ[jiîùÖ~gwѸŸ "8ÞF¯ŸsC©SXf{¾•à„c Ç<ßZ+íúVJ¹ç[q§=<3D>…f¿§Ê—*ZM<5A>´ã؃ç[㺞+ùÝ<C3B9>“œâZi·Ö

1
problems/G-70.out Normal file
View file

@ -0,0 +1 @@
blgy lab at ucf has rcntly been hvng prblms trnsmttng gntc sqncs btwn cmptrs.nfrtntly,crrnt systm rprsnts gntc sqncs as a strng of chrctrs,'a','c','g','t'.in order to speed up data trnsfrs you have been tskd with cmprssng data.lckly for you,your prfssr dvsd an easy way to do this,but he gave you task of ctlly mplmntng it.he said that if you cnsdr each of these lttrs as a nmbr in bs-4,such that 'a' = 0,'c' = 1,'g' = 2,'t' = 3,then any gntc sqnc has a nq bs-10 rprsnttn.he needs you to mplmnt a prgrm that will cnvrt a strng dscrbng a gntc sqnc to a bs-10 nmbr,or vc-vrs,given a bs-10 nmbr,opt crrspndng gntc sqnc.prblm,given a gntc sqnc,opt crrspndng bs-10 nmbr.lkws,given a nmbr in bs-10,opt crrspndng gntc sqnc.ipf first line of ipt will cntn a pstv ntgr,q,rprsntng nmbr of sqncs to cnvrt.next q lines will cntn thr an ntgr,n,1<=n<=2^{30}-1,which rprsnts a bs-10 nmbr,is grntd to have no ldng zrs,or a gntc sqnc,rprsntd by a strng of chrctrs 'a','c','g' nd/r 't',grntd to have no ldng a,btwn 1,15 chrctrs in lngth.opf for each sqnc,opt hdr sqnc #j,where j rprsnts sqnc being prcssd,bgnnng with 1.fllwng hdr,opt thr crrspndng gntc sqnc for ntgr given,or crrspndng bs-10 nmbr for gntc sqnc.opt for each sqnc shld each be on its own opt line.spi 3 ccgt 16675 gggttc spo sqnc #1,16675 sqnc #2,ccgt sqnc #3,142129

View file

@ -352,6 +352,14 @@ struct file
}
};
bool invalidChar (char c)
{
return !(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)