Re: [gcj] t-shirts

2017-07-30 Thread Reynaldo Gil-Pons
quick question, did any of you was has been contacted by google? Cos I haven't 
received mine nor been contacted...

-- 
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/eda0c6ea-aa9e-4715-85e8-efea7d82a306%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] about problem query of death Distributed GCJ 2017

2017-06-08 Thread Reynaldo Gil-Pons
I received from another post a reference for a rule in distributed code jam 
environment I didn't know, that you can't send two consecutive messages between 
the same pair of nodes. So I changed that, and began debugging again, and 
finally got AC. I had a little bug, not counting the digits corresponding to 
the 0 node. At least my probability reasoning was OK, I'm sharing the code to 
reamin as proof of concept :) (only 20 checks per position were enough, 30 got 
TLE after correcting bug)


#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 < 20; 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);
Receive(1);
GetLL(1);
PutLL(1, ans);
Send(1);


}
else{
  int ans = sum;
  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){
  PutLL(0, -1);
  Send(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:56:49 AM UTC-4, Reynaldo Gil-Pons wrote:
> 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;
>  

Re: [gcj] about problem query of death Distributed GCJ 2017

2017-06-05 Thread Reynaldo Gil-Pons
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" <gil...@gmail.com> 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 <gil...@gmail.com>于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" <gil...@gmail.com> wrote:
> 
> >
> 
> > > In the analisis they explain a solution for the Small case, and point out 
> &

Re: [gcj] about problem query of death Distributed GCJ 2017

2017-06-05 Thread Reynaldo Gil-Pons
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 <gil...@gmail.com>于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" <gil...@gmail.com> 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.


Re: [gcj] about problem query of death Distributed GCJ 2017

2017-06-04 Thread Reynaldo Gil-Pons
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" <gil...@gmail.com> 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+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/b8d61e73-ddb2-4fdf-bb32-7c61929055a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] problem E query of death Distributed Code Jam 2017

2017-06-02 Thread Reynaldo Gil-Pons
I've just read the Contest Analysis of this problem, and I can't figure out why 
the solution to the Small Case cannot work for the Large one. Imagine we check 
every position 30 times, and there are 100 (a million seems very big to me) 
test cases, so the probability of getting WA is at most 1 - (1 - (1 / 2 ** 30)) 
** 100 which is less than 1e-3, which should give AC, but it doesn't. 
What's wrong here?

-- 
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/68f867c2-a16a-4795-aa00-f72a1802717d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] about problem query of death Distributed GCJ 2017

2017-06-02 Thread Reynaldo Gil-Pons
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+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/11b46b16-82c3-4824-b319-626b05cf9e76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.