Re: [gcj] about problem query of death Distributed GCJ 2017
OK, I didn't think anyone would like to review code... This is the overall explanation: first each node tries to sum values on an interval, and send answer to node 0. When a node notices it's wrong, sends a different info to node 0. Then node 0 solves the rest of the problem. If node 0 was the one that failed, then node 1 solves the rest of the problem... code (hope not too messy): #include #include #include #include "query_of_death.h" #include #include using namespace std; // Receive(int) // GetLL(int) // Send(int) // PutLL(int) // MyNodeId() // NumberOfNodes() typedef long long i64; const int MOD = 1 << 20; int main() { int n = GetLength(); int OFFSET = 1e6; int node = MyNodeId(); int nnodes = NumberOfNodes(); assert(nnodes == 100); int bad = -1; int sum = 0; srand(1); for(int i = OFFSET * node ; i < min(n, OFFSET * (node + 1)) ; i++){ int cur = GetValue(i); for(int j = 0; j < 33; j++){ int tmp = GetValue(i); if(tmp != cur){ bad = i; break; } } if(bad != -1){ break; } sum += cur; } if(node == 0){ if(bad != -1){ int ans = 0; for(int i = 1; i < nnodes; i++){ Receive(i); int cur = GetLL(i); assert(cur >= 0); ans += cur; } PutLL(1, -bad - 1); Send(1); PutLL(1, ans); Send(1); } else{ int ans = 0; int badi = -1; for(int i = 1; i < nnodes; i++){ Receive(i); int resp = GetLL(i); if(resp < 0){ badi = i; bad = -(resp + 1); }else ans += resp; } assert(bad >= 0); assert(badi > 0); for(int i = badi * OFFSET; i < min(n, (badi + 1) * OFFSET); i++){ if(i == bad)continue; //assert(i >= 0 and i < n); int ii = GetValue(i); ans += ii; assert(GetValue(i) == ii); } //assert(bad >= 0 and bad < n); ans += GetValue(bad); cout << ans << endl; PutLL(1, 0); Send(1); } } else{ if(bad == -1){ PutLL(0, sum); Send(0); } else{ PutLL(0, -bad - 1); Send(0); } } if(node == 1){ Receive(0); int resp = GetLL(0); if(resp < 0){ bad = -(resp + 1); Receive(0); int ans = GetLL(0); for(int i = 0; i < min(n, OFFSET); i++){ if(i == bad)continue; int ii = GetValue(i); ans += ii; assert(GetValue(i) == ii); } //assert(bad >= 0 and bad < n); ans += GetValue(bad); cout << ans << endl; } } return 0; } On Monday, June 5, 2017 at 9:48:24 AM UTC-4, Luke Pebody wrote: > If you are getting WA you have probably made a logical error somewhere. You > might have to post your code to know where. > > > On 5 Jun 2017 2:35 p.m., "Reynaldo Gil-Pons"wrote: > There are 100 computers, 1 microsecond = 1e-6 seconds, so time for reading > each number 30 times is: 10 ^ 8 * (0.2 * 10^ -6) / 100 * 30 = 6 seconds, so a > little bit above, but I have tested and it passes the time limit, although > giving WA, as if the probability reasoning were incorrect... > > > > > On Monday, June 5, 2017 at 12:59:48 AM UTC-4, Xiongqi ZHANG wrote: > > > 10^8 * 0.2 microsecond = 20 seconds while Time Limit is 2 second. > > > > > > > > > Reynaldo Gil-Pons 于2017年6月4日周日 下午7:39写道: > > > > 0.2 millisecons to read a single bit? They say 0.2 microseconds. I get WA > > when doing what I explained, in 1.7 seconds... > > > > > > > > > > > > On Friday, June 2, 2017 at 12:09:47 PM UTC-4, Luke Pebody wrote: > > > > > > > I would think it can't work on the large case because it takes 0.2 > > > milliseconds to read a single bit once and therefore 20 seconds to read > > > all 100M bits once and 10 minutes to read them 30 times. > > > > > > > > > > > > > > > > > > > > > On 2 Jun 2017 4:56 p.m., "Reynaldo Gil-Pons" wrote: > > > > > > > In the analisis they explain a solution for the Small case, and point out > > > it cannot work for the Large one. When I calculate the probabilities of > > > getting WA using 30 checks for each position, and assuming 100 > > > testcases (cant be more than this right?) I get less than 1 / 1000. But I > > > still get WA. I calculate an upper bound on the probability of failure as > > > 1 - (1 - 1 / (2 ** 30)) ** number_test_cases. Is there anything wrong? > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > >
Re: [gcj] about problem query of death Distributed GCJ 2017
If you are getting WA you have probably made a logical error somewhere. You might have to post your code to know where. On 5 Jun 2017 2:35 p.m., "Reynaldo Gil-Pons"wrote: There are 100 computers, 1 microsecond = 1e-6 seconds, so time for reading each number 30 times is: 10 ^ 8 * (0.2 * 10^ -6) / 100 * 30 = 6 seconds, so a little bit above, but I have tested and it passes the time limit, although giving WA, as if the probability reasoning were incorrect... On Monday, June 5, 2017 at 12:59:48 AM UTC-4, Xiongqi ZHANG wrote: > 10^8 * 0.2 microsecond = 20 seconds while Time Limit is 2 second. > > > Reynaldo Gil-Pons 于2017年6月4日周日 下午7:39写道: > 0.2 millisecons to read a single bit? They say 0.2 microseconds. I get WA when doing what I explained, in 1.7 seconds... > > > > On Friday, June 2, 2017 at 12:09:47 PM UTC-4, Luke Pebody wrote: > > > I would think it can't work on the large case because it takes 0.2 milliseconds to read a single bit once and therefore 20 seconds to read all 100M bits once and 10 minutes to read them 30 times. > > > > > > > > > On 2 Jun 2017 4:56 p.m., "Reynaldo Gil-Pons" wrote: > > > In the analisis they explain a solution for the Small case, and point out it cannot work for the Large one. When I calculate the probabilities of getting WA using 30 checks for each position, and assuming 100 testcases (cant be more than this right?) I get less than 1 / 1000. But I still get WA. I calculate an upper bound on the probability of failure as 1 - (1 - 1 / (2 ** 30)) ** number_test_cases. Is there anything wrong? > > > > > > > > > > > > -- > > > > > > You received this message because you are subscribed to the Google Groups "Google Code Jam" group. > > > > > > To unsubscribe from this group and stop receiving emails from it, send an email to google-code...@googlegroups.com. > > > > > > To post to this group, send email to googl...@googlegroups.com. > > > > > > To view this discussion on the web visit https://groups.google.com/d/ msgid/google-code/11b46b16-82c3-4824-b319-626b05cf9e76%40googlegroups.com. > > > > > > For more options, visit https://groups.google.com/d/optout. > > > > -- > > You received this message because you are subscribed to the Google Groups "Google Code Jam" group. > > To unsubscribe from this group and stop receiving emails from it, send an email to google-code...@googlegroups.com. > > To post to this group, send email to googl...@googlegroups.com. > > To view this discussion on the web visit https://groups.google.com/d/ msgid/google-code/b8d61e73-ddb2-4fdf-bb32-7c61929055a7%40googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/ msgid/google-code/cded6fcb-f302-42b2-98db-510d42d43980%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/CAECKw-Meq4LZR-F1arc7Jbnvp_-pC%2B8DFtzNCtwK6RQBHna58A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [gcj] about problem query of death Distributed GCJ 2017
There are 100 computers, 1 microsecond = 1e-6 seconds, so time for reading each number 30 times is: 10 ^ 8 * (0.2 * 10^ -6) / 100 * 30 = 6 seconds, so a little bit above, but I have tested and it passes the time limit, although giving WA, as if the probability reasoning were incorrect... On Monday, June 5, 2017 at 12:59:48 AM UTC-4, Xiongqi ZHANG wrote: > 10^8 * 0.2 microsecond = 20 seconds while Time Limit is 2 second. > > > Reynaldo Gil-Pons于2017年6月4日周日 下午7:39写道: > 0.2 millisecons to read a single bit? They say 0.2 microseconds. I get WA > when doing what I explained, in 1.7 seconds... > > > > On Friday, June 2, 2017 at 12:09:47 PM UTC-4, Luke Pebody wrote: > > > I would think it can't work on the large case because it takes 0.2 > > milliseconds to read a single bit once and therefore 20 seconds to read all > > 100M bits once and 10 minutes to read them 30 times. > > > > > > > > > On 2 Jun 2017 4:56 p.m., "Reynaldo Gil-Pons" wrote: > > > In the analisis they explain a solution for the Small case, and point out > > it cannot work for the Large one. When I calculate the probabilities of > > getting WA using 30 checks for each position, and assuming 100 > > testcases (cant be more than this right?) I get less than 1 / 1000. But I > > still get WA. I calculate an upper bound on the probability of failure as 1 > > - (1 - 1 / (2 ** 30)) ** number_test_cases. Is there anything wrong? > > > > > > > > > > > > -- > > > > > > You received this message because you are subscribed to the Google Groups > > "Google Code Jam" group. > > > > > > To unsubscribe from this group and stop receiving emails from it, send an > > email to google-code...@googlegroups.com. > > > > > > To post to this group, send email to googl...@googlegroups.com. > > > > > > To view this discussion on the web visit > > https://groups.google.com/d/msgid/google-code/11b46b16-82c3-4824-b319-626b05cf9e76%40googlegroups.com. > > > > > > For more options, visit https://groups.google.com/d/optout. > > > > -- > > You received this message because you are subscribed to the Google Groups > "Google Code Jam" group. > > To unsubscribe from this group and stop receiving emails from it, send an > email to google-code...@googlegroups.com. > > To post to this group, send email to googl...@googlegroups.com. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-code/b8d61e73-ddb2-4fdf-bb32-7c61929055a7%40googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-code+unsubscr...@googlegroups.com. To post to this group, send email to google-code@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/cded6fcb-f302-42b2-98db-510d42d43980%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.