diff --git a/.replit b/.replit index 62cae28..ba5d974 100644 --- a/.replit +++ b/.replit @@ -1,2 +1,2 @@ language = "cpp" -run = "g++ src/*.cpp -o compress -std=c++1y; echo Compilation done; ./compress cowntact.txt 85" +run = "g++ src/*.cpp -o compress -std=c++1y; echo Compilation done; ./compress cowntact.txt 55" diff --git a/A-70.out b/A-70.out new file mode 100644 index 0000000..074f889 Binary files /dev/null and b/A-70.out differ diff --git a/B-70.out b/B-70.out new file mode 100644 index 0000000..e163e3a --- /dev/null +++ b/B-70.out @@ -0,0 +1,5 @@ +cw-tpprs.bss runs quick cow.wvng trees,dckng under brnchs.looks bhnd.thy'r gttng clsr.heart pndng,sweat drppng down neck,bss knows needs fast.barn.too far away.sh'll never reach t--h crs.old cllr down river.bss veers left,gllps cllr.nsd,sh'll safe.rchs door.blast,door lckd.pnckd,bss ntcs red bttn side.knwng,taps bttn dsprt hoof,hpng.sddnly,rcrdng voice booms rnd frst.open door,must solve fllwng prblm,fj n cows took cntst,rslts.cow thr grnsy hlstn.since hlstns gnrlly xprncd cntsts,fj fgrs prbbly bttr cntst.wants fgr whthr true.spcfclly,strng lngth n.chrctr g h.chrctr ndcts breed rnk-n cow,forth.fgr nmbr pairs cows,one grnsy,one hlstn,grnsy tprfrmd hlstn.ipf ipt strng lngth n,1<=n<=100.chrctr thr g h.opf sngl ntgr,nmbr pairs +Original length: 1245 +Compressed length: 373 +Percent compression: 70.0402% +jyWհc_>u{7ytW}UB yghVef70&kMXbߠFuNUt}(m3/7띬Gyg}{9YWCQ[pʸ@ c]݌n]CN y8Q83^| IUlzaYoQyϘͲj}jCwSTtdS_Sײ7Ϻ&sPݹKcl(?H2WSJ]]Pz{5s X0Yj{ڏOUSJGIsOJ_бL5Zбڹ's%O-R*M٬l t,jo opc5K@„{LkpsGRsdA'}, diff --git a/C.out b/C.out index cfec2cb..a4feacc 100644 --- a/C.out +++ b/C.out @@ -2,4 +2,7 @@ vrybdy cloud cmptng days.tryng smpl one,sell mchns one two btchs clld slots.cstm Original length: 1144 Compressed length: 171 Percent compression: 85.0524% -z=y^}>y<|>gv]k5Mzo7yw{^Wunvn[-|_z^W}{om6yo{w;N}o[kZ-y +�z=�y�^�}>�y<�|>�g�v�]�k5�M�z�o7�y�w�{�^�W�u�n�v�n�[-�|�_�z�^�W�}�{�o�m6�y�o�{�w;�N�}�o�[�k�Z-�y� + + +Everybody could computing days. Trying sample one, sell machines one or two batches collide slots. Customer buy one second cpu q seconds integer q. Input consists single line containing four integers q, 2<=q<=100, ndd complete longer batches, m, 1<=m<=1000000, machines owned, s, 0<=s<=1000000, 1-second slots purchased, l, 0<=l<=1000000, q -second slots purchased \ No newline at end of file diff --git a/D-70.out b/D-70.out new file mode 100644 index 0000000..e69de29 diff --git a/E-70.out b/E-70.out new file mode 100644 index 0000000..23e0345 --- /dev/null +++ b/E-70.out @@ -0,0 +1,6 @@ +c++ dvsn pstv ntgrs lwys rnds down.smtms two ntgrs dvdd same dvsr bcm equal thgh rgnlly equal.5/4,7/4 both equal 1,5!=7.given list nnngtv ntgrs,dvsr.ipf line ipt cntns two ntgrs n,1<=n<=200000,nmbr lmnts list,d,1<=d<=10^9,dvsr.scnd line ipt cntns n ntgrs _1,...,_n,0<=_<=10^9,where a_i i th lmnt list.opf dsply sngl ntgr ndctng nmbr dstnct pairs ndcs (i,j) 1<=*REk77ȮY.2}_=ЮI9d-2қqG]];Go +OeG-kvYeM1xTx^X9MkgvO-VOtDt.'mv7 diff --git a/F-70.out b/F-70.out new file mode 100644 index 0000000..e69de29 diff --git a/G-70.out b/G-70.out new file mode 100644 index 0000000..05d0665 --- /dev/null +++ b/G-70.out @@ -0,0 +1 @@ +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/G.out b/G.out index d8cedd9..7bcb284 100644 --- a/G.out +++ b/G.out @@ -2,4 +2,8 @@ blgy lab ucf rcntly hvng prblms trnsmttng gntc sqncs cmptrs.nfrtntly,crrnt rprsn Original length: 1592 Compressed length: 238 Percent compression: 85.0503% -z=y^Wj5F}>Ot]Wz=Gt]~o[km6s\u:}>x^WUu].r{^z=aXu:o?yww]k5 APTUjv]Wu:cXkZV +�z=�y�^�W�j5�F�}>�O�t�]�W�z=�G�t�]�~�o�[�k�m6�s�\�u:��}>�x�^�W�U�u�].�r�{�^�z=�a�X�u:��o�?�y�w�w�]�k5 �A�P�T�U�j�v�]�W�u:�c�X�k�Z�V�� + +Biology lab recently having problems transmitting genetic sequences to computers. Unfortunately, currently represents genetic sequences string characters gcat. luckily, professor easy gave task to implementing + +given Q sequences whether in GCAT or base 10, output base 10 or GCAT \ No newline at end of file diff --git a/H-70.out b/H-70.out new file mode 100644 index 0000000..e69de29 diff --git a/cowntact.txt b/cowntact.txt index 23fc638..7214c55 100644 --- a/cowntact.txt +++ b/cowntact.txt @@ -1,62 +1,95 @@ -Farmer John is worried for the health of his cows (conveniently numbered -$1 ... N$ as always) after an outbreak of the highly contagious bovine -disease COWVID-19. - -Recently, Farmer John tested all of his cows and found some of them to be -positive for the disease. Using video footage from inside his barn, he is able -to review recent interactions between pairs of cows --- it turns out that when -cows greet each-other, they shake hooves, a gesture that can unfortunately -spread the infection from one cow to another. Farmer John assembles a -time-stamped list of interacting pairs of cows, with entries of the form -$(t, x, y)$, meaning that at time $t$, cow $x$ shook hooves with cow $y$. -Farmer John also knows the following: - -(i) Exactly one cow on his farm could have started out carrying the disease -(we'll call this cow "patient zero"). - -(ii) Once a cow is infected, she passes the infection along with her next $K$ -hoof shakes (possibly including the same partner cow several times). After -shaking hooves $K$ times, she no longer passes the infection along with -subsequent hoof shakes (since at this point she realizes she is spreading the -infection and washes her hooves carefully). - -(iii) Once a cow is infected, she stays infected. - -Unfortunately, Farmer John doesn't know which of his $N$ cows is patient zero, -nor does he know the value of $K$! Please help him narrow down the -possibilities for these unknowns based on his data. It is guaranteed that at -least one possibility is valid. - -INPUT FORMAT -The first line of the input file contains $N$ ($2 <= N <= 100$) and $T$ -($1 <= T <= 250$). The next line contains a string of length $N$ whose -entries are 0s and 1s, describing the current state of Farmer John's $N$ cows ---- 0 represents a healthy cow and 1 represents a cow presently with the -disease. Each of the next $T$ lines describes a record in Farmer John's list of -interactions and consists of three integers $t$, $x$, and $y$, where $t$ is a -positive integer time of the interaction ($t <= 250$) and $x$ and $y$ are -distinct integers in the range $1 \ldots N$, indicating which cows shook hands -at time $t$. At most one interaction happens at each point in time. - -OUTPUT FORMAT -Print a single line with three integers $x$, $y$, and $z$, where $x$ is the -number of possible cows who could have been patient zero, $y$ is the smallest -possible value of $K$ consistent with the data, and $z$ is the largest possible -value of $K$ consistent with the data (if there is no upper bound on $K$ that -can be deduced from the data, print "Infinity" for $z$). Note that it might be -possible to have $K=0$. - -SAMPLE INPUT -4 3 -1100 -7 1 2 -5 2 3 -6 2 4 - -SAMPLE OUTPUT -1 1 Infinity - -The only candidate for patient zero is cow 1. For all $K>0$, cow 1 infects cow 2 -at time 7, while cows 3 and 4 remain uninfected. - - +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 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). + +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. + +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. + +For a C++ solution, use this template: + +#include "grader.h" + +void addRoad(int a, int b){ + // Fill in code here +} + +void buildFarms(){ + // Fill in code here +} + +void notifyFJ(int a, int b){ + // Fill in code here +} +For a Java solution, use this template: + +import java.io.IOException; +// If you find it necessary, you may import other standard libraries here. +public class boxes extends Grader { + + // Copy this exactly: + +@Override + public static void main(String args[]) throws IOException { new boxes().run(); } + + +@Override + public void addRoad(int a, int b) { + // Fill in code here + } + +@Override + public void buildFarms(){ + // Fill in code here + } + +@Override + public void notifyFJ(int a, int b){ + // Fill in code here + } +} +Sample Interaction + +Grader calls addRoad(0,1) + +Grader calls addRoad(1,2) + +Grader calls buildFarms() + +Solution calls setFarmLocation(0,1,1) + +Solution calls setFarmLocation(1,1,2) + +Solution calls setFarmLocation(2,2,2) + +Solution ends buildFarms() + +Grader calls notifyFJ(0,0) + +Solution calls addBox(1,1,1,1) + +Solution ends notifyFJ(0,0) + +Grader calls notifyFJ(0,2) + +Solution calls addBox(1,1,1,2) + +Solution calls addBox(2,2,2,2) + +Solution ends notifyFJ(0,2) + +Grader terminates, and solution passes test-case + +(Note: if you do not pass the first test case, the grader will indicate this as usual. However, note that the short sample interaction above does not correspond to the first test case or any other). + +Problem credits: Spencer Compton \ No newline at end of file diff --git a/src/decode.cpp b/src/decode.cpp index b812dae..451b51e 100644 --- a/src/decode.cpp +++ b/src/decode.cpp @@ -2,7 +2,7 @@ #include "huffman.h" /*int main() { - ifstream enc("êõz=Çãñx¼Þïw»]®W«Õj5F£Ñèôz=žO'“Éär¹\\®×k5šÍf³Y¬V«Õj5†Ãa°X¬ÖkµZ­V«UªUªUªÕjµÚív»Ýî÷ûý~?"); + ifstream enc("A.out"); stringstream ss; ss << enc.rdbuf(); string s = ss.str(); diff --git a/src/encode.cpp b/src/encode.cpp index 71ee6a2..1e458d3 100644 --- a/src/encode.cpp +++ b/src/encode.cpp @@ -71,6 +71,7 @@ weightstruct getweight(string s) } void preprocessword(int stage,string& s,string& next,int pos) { + if(s.length()<2)return; if(stage==-1)//after deleting low weights { if(s[0]=='$') @@ -473,4 +474,4 @@ int main(int argc, char *argv[]) { cout << "Compressed length: " << (enc.size() + 7) / 8 << '\n'; cout << "Percent compression: " << 100.0 - (double)100.0 * (enc.size() + 7) / 8 / orig.size() << "%\n"; }*/ -} +} \ No newline at end of file