[gcj] Re: Runtime error with ruby

2020-01-13 Thread Xiongqi ZHANG
Took me a while to debug since I am not familiar with Ruby at all.

For some reason, res.sum is not supported.

Removing `res.sum == amount &&` from valid_res?(res, amount) resolve the 
problem

Also you don't need to do that check because it is always true anyway.
Also res[i] will never be 4, so the `if res[1] == 4` block will never be 
run anyway.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/c71cf82d-d6cf-41b1-b6be-b3f915e9384d%40googlegroups.com.


Re: [gcj] Practice Round 2019 - Kick Start - Mural - Runtime Error ( Java )

2020-01-13 Thread Xiongqi ZHANG
I tried your code, it returns WA(Wrong answer) instead of RE(Runtime Error)

Please check if you selected the correct language. You should use
Java(OpenJDK)

Pandelis  于2020年1月13日周一 上午7:28写道:

> Hey all,
> I am new to this. I tried submitting the code for one of the Kick Start
> problems; I keep on getting a run-time error from google, but when I run
> the code on my machine it executes perfectly. Can someone help me out?
>
> code :
>
> import java.util.*;
> import java.io.*;
>
> class Section {
>private int id;
>private int value;
>private boolean painted;
>
>public Section( int id, int value ) {
>   this.id = id;
>   this.value = value;
>   this.painted = false;
>}
>
>public int getId() {
>   return this.id;
>}
>public int getValue() {
>   return this.value;
>}
>
>public void paint() {
>   this.painted = true;
>}
>
> }
>
> class Solution {
>
>public static void main(String[] args) throws Exception {
>   int testCases;
>   int wordSize;
>   String word;
>   int totalBeauty;
>
>   Section[] wall;
>
>   int tmpTotalBeauty;
>
>   Scanner in = new Scanner(new BufferedReader(new
> InputStreamReader(System.in)));
>   testCases = in.nextInt();
>
>   for (int count = 0; count < testCases; count++) {
>  wordSize = in.nextInt();
>  in.nextLine(); // flush
>  word = in.nextLine();
>  totalBeauty = 0;
>  wall = new Section[wordSize];
>
>  for (int i = 0; i < wall.length; i++) {
> wall[i] = new Section( i, Character.getNumericValue(
> word.charAt( i ) ) );
>  }
>
>  for (int pivot = 0; pivot < (wordSize+1)/2; pivot++) {
> tmpTotalBeauty = 0;
>
> for (int i = 0; i < (wordSize+1)/2; i++) {
>//System.out.println(wall[pivot+i].getValue());
>tmpTotalBeauty += wall[pivot+i].getValue();
> }
> if (totalBeauty < tmpTotalBeauty) {
>totalBeauty = tmpTotalBeauty;
> }
>  }
>
>
>  System.out.println("Case #" + (count+1) + ": " + totalBeauty);
>   }
>
>   //in.close();
>
>}
> }
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/b18b3e1d-70fb-4585-9efe-aab56a72ccf4%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAGDEU-KoVg5L87f96hcUSs1sYne5LezmHSmXKYgozKG%2BHfyutg%40mail.gmail.com.


[gcj] Re: Runtime error with ruby

2020-01-13 Thread Xiongqi ZHANG
http://viarails.net/q/How-to-sum-an-array-of-numbers-in-Ruby

According to the article above, .sum method for enumerables only works with 
Rails, not with regular Ruby code.

That could be the reason why you get RE

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/b6555944-104c-4b65-a04b-d73495c80436%40googlegroups.com.


[gcj] Re: What is the issue of the code?

2019-12-17 Thread Xiongqi ZHANG
Can you provide more context?

e.g.
1. What is the problem you are trying to solve?
2. What is the issue you are getting? Program crashed? Unexpected output is 
generated? etc...
3. What is the language you are using? What is the compiler/interpreter you 
are using and the version?



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/77703876-6ab2-42bb-80ab-49cea67020f0%40googlegroups.com.


[gcj] Re: Code provoking Runtime Error when it seemingly outputs the correct answer

2019-11-08 Thread Xiongqi ZHANG
Hey can you try again?
Your code passed both test case when I submit.

Hi Xiongqi,
>
> I am getting a TLE when I tried to implement as per the analysis. Where am 
> I going wrong? Appreciate your help.
>
> def solve(N, P, R):
> torn = set(P)
> store = []
> for i in range(1, N + 1):
> ctr, fac = 0, 1
> while i * fac <= N:
> if i * fac not in torn:
> ctr += 1
> fac += 1
> store.append(ctr)
> return sum(map(lambda x: store[x - 1], R))
> 
> if __name__ == '__main__':
> T = int(input())
> for i in range(T):
> N, M, Q = map(int, input().split(' '))
> P = list(map(int, input().split(' ')))
> R = list(map(int, input().split(' ')))
> print('Case #{}:'.format(i +  1), solve(N, P, R))
>
> On Wednesday, November 6, 2019 at 8:52:16 AM UTC+8, Xiongqi ZHANG wrote:
>>
>> Your code looks good to me, except it is too slow to even pass the 
>> visible test. (getting TLE verdict instead of RE)
>> It might be the case that you submitted the code with python2?
>>
>> I slightly improved your code using the approach suggested by analysis 
>> and passed both visible and hidden test.
>> Check out the code below
>>
>>
>> *t = int(input())*
>> *for test in range(1, t + 1):*
>> *  n, m, q = map(int, input().split())*
>>
>> *  p = set([int(e) for e in input().split()])*
>> *  r = [int(e) for e in input().split()]*
>>
>> *  tmp = [sum([1 for page in range(i, n + 1, i) if page not in p]) for i 
>> in range(1, n + 1)]*
>>
>> *  result = sum([tmp[reader - 1] for reader in r])*
>>
>> *  print("Case #{}: {}".format(test, result))*
>>
>>
>>
>> Hi,
>>> I'm new to doing Google Kickstart challenges and I tried doing the first 
>>> on the latest problem set (Book Reading). I did it in Python and the code 
>>> outputs the correct answer on my local machine, however it throws a RE when 
>>> I try to submit my answer.
>>>
>>> Here is the code:
>>>
>>> t = int(input())
>>> for test in range(1, t + 1):
>>>  n, m, q = map(int, input().split())
>>>
>>>  p = [int(e) for e in input().split()]
>>>  r = [int(e) for e in input().split()]
>>>
>>>  result = 0
>>>  for reader in range(q):
>>>result += sum([1 for page in range(1, n + 1) if page % r[reader] == 0 
>>> and page not in p])
>>>
>>>  print("Case #{}: {}".format(test, result))
>>>
>>> Thanks for your help.
>>>
>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/db64423c-c568-4b3c-8986-49bdb37dd823%40googlegroups.com.


[gcj] Re: Help me to find out my mistake

2019-11-08 Thread Xiongqi ZHANG
Can you try the following case?

1
2
0900 0930
0930 1000

The expected result should be 2.

Because the 1st train departs at 9:30 and the 2nd train arrives at the same 
time, so you need at least 2 platform.


P.S. This is a group very specific to Google Code Jam. Please refrain from 
asking questions about problems that are not related to Google Code Jam.


Problem Link :  
> https://practice.geeksforgeeks.org/problems/minimum-platforms/0/?track=md-arrays=144
>
> My Code:
>
> #code
> def minimumPlatforms(a,b,n):
> a.sort()
> b.sort()
> platform = 1
> result = 1
> i = 1
> j = 0
> while(i if(a[i] platform += 1
> i += 1
> if(platform > result):
> result = platform
> else:
> platform -= 1
> j += 1
> return result
> for _ in range(int(input())):
> n = int(input())
> a = [int(x) for x in input().strip().split()]
> b = [int(x) for x in input().strip().split()]
> print(minimumPlatforms(a,b,n))
>
>
> I can't get my mistake. It gives proper output for sample test cases but 
> gives wrong output while I submit the code.
> I request everyone to please find it.
> I attach screenshots of output.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/e193c120-89e2-4f4e-ad51-7e8c3558d1f1%40googlegroups.com.


[gcj] Re: Code provoking Runtime Error when it seemingly outputs the correct answer

2019-11-05 Thread Xiongqi ZHANG
Your code looks good to me, except it is too slow to even pass the visible 
test. (getting TLE verdict instead of RE)
It might be the case that you submitted the code with python2?

I slightly improved your code using the approach suggested by analysis and 
passed both visible and hidden test.
Check out the code below


*t = int(input())*
*for test in range(1, t + 1):*
*  n, m, q = map(int, input().split())*

*  p = set([int(e) for e in input().split()])*
*  r = [int(e) for e in input().split()]*

*  tmp = [sum([1 for page in range(i, n + 1, i) if page not in p]) for i in 
range(1, n + 1)]*

*  result = sum([tmp[reader - 1] for reader in r])*

*  print("Case #{}: {}".format(test, result))*



Hi,
> I'm new to doing Google Kickstart challenges and I tried doing the first 
> on the latest problem set (Book Reading). I did it in Python and the code 
> outputs the correct answer on my local machine, however it throws a RE when 
> I try to submit my answer.
>
> Here is the code:
>
> t = int(input())
> for test in range(1, t + 1):
>  n, m, q = map(int, input().split())
>
>  p = [int(e) for e in input().split()]
>  r = [int(e) for e in input().split()]
>
>  result = 0
>  for reader in range(q):
>result += sum([1 for page in range(1, n + 1) if page % r[reader] == 0 
> and page not in p])
>
>  print("Case #{}: {}".format(test, result))
>
> Thanks for your help.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/de68a956-63f5-4139-8de4-ee91bb74d5e9%40googlegroups.com.


[gcj] Re: Any bug in my upsolve solution for Kickstart Round F problem "The Equation"

2019-10-29 Thread Xiongqi ZHANG
It is an overflow problem.

2^59 * 1000 is greater than 2^63 which will cause overflow.

try 53 and it will pass

在 2019年10月28日星期一 UTC-7上午7:47:55,Pinku Deb Nath写道:
>
> Hi ^_^,
>
> Is there any silly bug in my code that I missed: 
> https://pastebin.com/KJ1FZKed
>
> problem link: 
> https://codingcompetitions.withgoogle.com/kickstart/round/00050e02/0018fe36
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/b3221371-ea19-440c-880e-f2f959b9dd83%40googlegroups.com.


[gcj] Re: Analysis part of the competetive code jam

2019-09-23 Thread Xiongqi ZHANG
Analysis is only available after the contest ended and served as education 
purpose.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/85037dce-4b52-44d7-ae61-fb1f3196d544%40googlegroups.com.


[gcj] Re: Help with the Training Problem

2019-08-11 Thread Xiongqi ZHANG
Please read FAQ for more information.

Something to note:

1. You must name your main class Solution (with exactly that capitalization). 
It must contain a public main method. Furthermore, your code must not contain 
any package definitions. (Note: Package declarations are allowed in Kotlin.)

2. You need to print your answer in given format, i.e. Case #x: ans
where x is the case number starting from 1 and ans is the answer that test case.

I slightly changed your code to address the issues above.

```Java
import java.util.*;
import java.io.*;

class Solution {

public static int minSum(ArrayList list) {
int len = list.size();
int sum = 0;
Collections.sort(list);
Collections.reverse(list);
//System.out.println(list);
for (int i = 1; i < len; i++) {
sum += list.get(0) - list.get(i);
}
return sum;
}

public static void main(String[] args) throws IOException {
BufferedReader ip = new BufferedReader(new 
InputStreamReader(System.in));
int t = Integer.parseInt(ip.readLine());
for (int cas = 1; cas <= t; cas++) {
String[] firstLine = ip.readLine().trim().split(" ");
String[] secondLine = ip.readLine().trim().split(" ");

int N = Integer.parseInt(firstLine[0]);
int P = Integer.parseInt(firstLine[1]);

ArrayList skillList = new ArrayList();

for (int i = 0; i < N; i++) {
skillList.add(Integer.parseInt(secondLine[i]));
}
Collections.sort(skillList);

int min = Integer.MAX_VALUE;

for (int i = 0; i <= N - P; i++) {
ArrayList temp = new ArrayList();
for (int j = 0; j < P; j++) {
temp.add(skillList.get(i + j));
}
if (min > minSum(temp)) {
min = minSum(temp);
}
}
System.out.printf("Case #%d: %d%n", cas, min);
}
}
}
```
Your solution gave correct result for test set 1 (the visible test) but it is 
not good enough to pass the test set 2 (the hidden test) as it is too slow to 
meet the running time restriction. 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/f4361956-744f-4e41-85f2-7aaac43f8ed4%40googlegroups.com.


[gcj] Re: Check if matrix formation is possible or not?

2019-06-02 Thread Xiongqi ZHANG
I assume your input is actually

3 3 (3x3 matrix)
2 1 0 (3 rows)
1 2 0 (3 cols)

or

3 2 (3x2 matrix)
2 1 0 (3 rows)
1 2 (2 cols)


The answer will be

XXO
OXO
OOO

or

XX
OX
OO


In order to have a valid solution, 

1. you need to first check if the sum of rows and sum of cols are equal.
If not, there is no doubt that such matrix wouldn't exist

2. For each number X in rows, check if there are at least X cols that is still 
non-zero, if not, there is no valid matrix; if yes, subtract 1 from the X 
highest cols.

3. repeat step 2 until all cols goes to 0



> There is a coding problem where we are given some inputs and we have to tell 
> if a matrix can be made or not.
> we are given the size of the matrix. Then the second line of the input, 
> signifies the row of the matrix. It some numbers. And the third line 
> signifies column.
> 
> Example: 3 3 (size of matrix)
> 2 1 0 (rows of the matrix)
> 1 2 (column of the matrix)
> 
> 
> 
> In the second line, 2 implies that the two elements of the first row has to 
> be filled with X while others will be zero. 1 says that only one element of 
> the second row will be populated with X and similarly, 0 means the third row 
> has no X populated.
> 
> Similarly, in 3rd line, 1 refers to that only 1 element in the first column 
> should be filled with X. and 2 says that two elements in the second column 
> are filled with X.
> 
> 
> So if we follow this, we wont have any combination that will satisfy our 
> matrix.
> 
> Any idea how can I implement such an algorithm that will check if the matrix 
> is possible or not. When I am creating examples, I feel that there is a 
> pattern in the input that i am missing. So it will be great if anyone can 
> suggest me if i am missing anything.
> 
> Thanks in advance.
> 
> I was asked this question in an amazon interview. I am really confused how 
> much more do I need to practise.

-- 
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/8c8d81bf-5db5-4a8e-bad1-47da0a3f9d89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Need help to find out why my program got a TLE in New Elements Part 1

2019-05-20 Thread Xiongqi ZHANG
It is technically possible that your program would run into a dead loop.

Inside function `Count(double low, double high, const vector& data)`,
if your `low` and `high` is big, say around 1e10, and they are very close to 
each other, such that (low + high) * 0.5 is either low or high, but high - low 
> 1e-11 (due to precision lost in double), and low and high give different 
order of data

your program will keep calling Count(low, high, data) indefinitely.

I cant think of a sample data that would make it happen though.


> Dear all,
> 
> I want to know why I receive a TLE for the small data set with the 
> program below. All your help are appreciated! (I failed to reproduce the 
> RE/TLE myself. So I need an exact data set that fails to work.)
> 
> Or is there any difference between the judge environment and by PC?
> 
> P.S. No need to point me to the good solution. I've got one myself, sadly 
> only 30 mins after the round completes.
> 
> Regards,
> WC Leung.
> 
> 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> 
> using namespace std;
> 
> struct Item {
> int a;
> int b;
> int index;
> };
> 
> double factor = 0.0;
> 
> vector data1;
> vector data2;
> 
> bool compare(Item left, Item right) {
> double l = factor * left.a + 1.0 * left.b;
> double r = factor * right.a + 1.0 * right.b;
> return l < r || (l == r && left.index < right.index);
> }
> 
> int Count(double low, double high, const vector& data) {
> data1 = data;
> data2 = data;
> factor = low;
> sort(data1.begin(), data1.end(), compare);
> factor = high;
> sort(data2.begin(), data2.end(), compare);
> 
> bool same = true;
> for (int i = 0; i < (int) data.size(); ++i) {
> if (data1[i].index != data2[i].index) {
> same = false;
> break;
> }
> }
> 
> if (!same) {
> if (high - low < 0.001)
> return 1;
> 
> double mid = (low + high) * 0.5;
> int count = Count(low, mid, data) + Count(mid, high, data);
> return count;
> }
> 
> return 0;
> }
> 
> void solve(int caseNo) {
> std::cout << "Case #" << caseNo << ": ";
> 
> int n;
> cin >> n;
> 
> vector data;
> 
> for (int i = 0; i < n; ++i) {
> Item item;
> cin >> item.a >> item.b;
> item.index = i;
> 
> data.push_back(item);
> }
> 
> cout << (Count(0.001, 1000, data) + 1) << "\n";
> }
> 
> int main(int argc, char** argv) {
> int N;
> std::cin >> N;
> std::string str;
> std::getline(std::cin, str);
> 
> for (int i = 0; i < N; ++i) {
> solve(i + 1);
> }
> 
> return 0;
> }

-- 
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/6d38f7c7-ca5d-4e3a-b909-bb9275590432%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] question about alien rhyme

2019-04-24 Thread Xiongqi ZHANG
why would you ignore “scent”? even though “scent”
also has “cent” as a suffix, it can still be used to match other words with
different suffix, e.g “went” with rhyme “ent”.

On Wed, Apr 24, 2019 at 8:12 AM Lasse  wrote:

> Hi /dev/joe,
>
> thank you for the reply. I think our understanding is the same. With your
> example, I first match rhyme "cent", which is shared by "cent" and
> "recent", then "scent" must be ignored in the other matches, right?
>
> I did so and my submission is wrong, but when I retained "scent" and only
> ignored "cent" and "recent", my code works with small dataset.
>
> Lasse
>
> On Tuesday, April 23, 2019 at 10:59:35 PM UTC+2, /dev/joe wrote:
> > The problem is about matching pairs of rhymes. Apparently we know that
> the poems in this alien language only ever use each rhyming-ending twice.
> Or maybe it's that we want to see how complex the rhyme scheme could be, in
> terms of different rhyming endings. Since rhymes are determined based on
> the location of an accent in the word, and we don't know where the accents
> go, you are placing the accents anywhere and trying to determine the
> maximum number of rhymes possible as a way of helping to decide whether
> these words are from a poem. Here's the relevant text from the problem:
> >
> > You believe that you can discard zero or more of these words, assign
> accented letters to the remaining words, and then arrange those words into
> pairs such that each word rhymes only with the other word in its pair, and
> with none of the words in other pairs.
> >
> > You want to know the largest number of words that can be arranged into
> pairs in this way.
> >
> >
> >
> > Example: Suppose you get the words bent, cent, dent, gent, lent, rent,
> recent, sent, scent, tent, and went.
> >
> > You can make two words rhyme with ending t, two with nt, two with ent,
> and two with cent. You will have three leftover words, but no more common
> endings which are not already used, so you can't make another pair even
> though the words have a common ending.
> >
> >
> > Using the method of working from longest ending to shortest, you won't
> find any matches until you get to cent. There are three there, and you use
> and eliminate two and move on to the next ending. Then you get to ent, nt,
> and t, each of which have all the remaining words at that time. You use two
> each time, any two, and move on. When you are done, you have three words,
> each of which ends with t, nt, ent, and maybe even one of them with cent,
> but you are not allowed to rhyme more than two words with any ending, so
> you can't use them.
> >
> >
> > If ascent was added to the list, you could rhyme ascent with scent
> (based on the ending scent), recent with cent, and three more pairs with
> the shorter endings, allowing you to use 10 words, but you would still have
> two left over which match their final three letters but can't be used
> because they don't have any common endings that are not already used.
> >
> >
> >
> >
> > On Tue, Apr 23, 2019 at 2:04 PM Lasse  wrote:
> > I was playing with the question Alien Rhyme in round 1a 2019 and found
> >
> > something strange. Please correct me if I was wrong or remind me when it
> >
> > is already discussed.
> >
> >
> >
> > I tried to collect all matched rhymes and select from longest to
> >
> > shortest, but when I filter all matched (with rhyme), the small dataset
> >
> > failed; but when I removed only the first two matched words, at least
> >
> > the small dataset succeeded. Actually I tried to use the method from
> >
> > ACRushTC, when I used a similar method, both datasets passed when I
> >
> > removed the first two matched but both failed when I removed all
> >
> > matched. Did I understand the question in the wrong way? As I
> >
> > understood, the words which have longer rhyme will be ignored.
> >
> >
> >
> > --
> >
> > 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 googl...@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/d8d001bc-124e-45cb-bfb5-3a6d1482b1f3%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/73c01868-d7e5-430d-a130-78efac477b76%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 

[gcj] Re: Possible Bug in C++ compiler (Golf Gophers CJ 2019 Round A)

2019-04-16 Thread Xiongqi ZHANG
Would you mind sharing your code?

And I assume you know the consequence of using those fastIO tricks.

> ios_base::sync_with_stdio(false);

This means you can no longer mix scanf/cin or printf/cout

> cin.tie(NULL);

This means cout (or any other stream) will NOT be flushed before you read any 
data from cin.


I highly discourage using any fast I/O trick in interaction problem because the 
data your program is not a static file but generated using your output.
Any fast I/O trick that put cin/cout un-synced would cause unexpected result. 


> Golf Gophers was an interactive problem that was asked recently in CodeJam 
> Round A.
> 
> I used fast IO during the contest but I was getting TLE verdict because i was 
> using :
> 
> ios_base::sync_with_stdio(false);cin.tie(NULL);
> 
> After the contest, when I tried to run it without the above line of code it 
> passed. 
> 
> Now this line of code is being used by C++ programmers for ages for fast IO 
> but for some reason it didn't work during the contest.
> 
> Can we not use fast io in interactive problems or is this a bug in compiler?

-- 
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/7d594e14-8346-4eff-8e71-69f52a7a52c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Golf Gophers python 3 TLE

2019-04-13 Thread Xiongqi ZHANG
possible = [i for i in possible if i%primes[night] == sum(a)]

it should be sum(a) % primes[night]


On Sat, Apr 13, 2019 at 2:51 PM Saeon Piremakumar 
wrote:

> Kept getting a TLE for this problem, is my code slow or is it just wrong
> somewhere
> .
> # CODE #
> import sys
> t, n, m = map(int, input().split())
>
> def solve(n,m):
>
> primes = [16,9,5,7,11,13,17]
> possible = list(range(1,m+1))
> for night in range(n):
> for dummy in range(18):
> print (primes[night],end = " ")
> sys.stdout.flush()
>
> a = list(input().split())
> a = [int(i) for i in a]
> possible = [i for i in possible if i%primes[night] == sum(a)]
> if len(possible) == 1:
> print(possible[0])
> sys.stdout.flush()
> break
>
> for _ in range(t):
> solve(n,m)
>
> ###
> Thanks
>
> --
> 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/23e6dabb-6c75-4188-8b4a-18a3e52b029b%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/CAGDEU-KJuWSoq4Wk7zR4XC7bV%2B2S4wgXfhDXZwmPdSjx0j0vTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: cryptopanagram RE error

2019-04-12 Thread Xiongqi ZHANG
Your statement is wrong. 2 is still a valid prime in the test case.

Your quote comes from a paragraph which starts with `For example, suppose ...`, 
which means it is just an assumption of ONE test case, not ALL test case.

> In the question, they have mentioned that factors are odd numbers so prime 
> number "2" is also invalid. 
> Note: "because we worry that it is too easy to factor even numbers."

-- 
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/fb9174c6-9435-4f02-bbaf-eabbaed32872%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Can I expect any help from this community at all?

2019-04-12 Thread Xiongqi ZHANG
to ACTECH:

I posted some simple testcase for Cryptopangrams.
I believe your program does not produce expected result for those cases.

Feel free to use it for debugging. Once you fixed them and still couldn't pass 
the online evaluation, we can take another look.

-- 
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/88e318c3-2728-4ca0-abce-9cbf12d4e3eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Question 3 runtime error

2019-04-12 Thread Xiongqi ZHANG
Feel free to try this solution

1
10 6
49 49 14 6 6 6

Expected output
CCCABAB

-- 
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/df81c0e4-06ad-4d36-b239-45ba1a8ad32e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Cryptopangrams solution in Python and C# generates RE

2019-04-12 Thread Xiongqi ZHANG
Try this case
1
10 6
49 49 14 6 6 6


Expect A = 2, B = 3, C = 7
output should be 

CCCABAB

Your python solution crashed with `ZeroDivisionError: integer division or 
modulo by zero` error.

I guess the C# solution would crash for the same reason.

-- 
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/b1cef1e2-d36c-4d0d-a452-7a96b399c56a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] GCJ 2019 Qualification Round: Cryptopangram; help me resolve RE status

2019-04-12 Thread Xiongqi ZHANG
You can try this input
1
10 6
291 291 6 6 6 6 


expect A = 2, B = 3, C = 97
result is BCBABAB

But your program crash with `integer division or modulo by zero`

> On Thursday, April 11, 2019 at 12:21:58 AM UTC+5:30, F S wrote:
> > On Monday, April 8, 2019 at 10:40:24 PM UTC+2, Abhishek Kalahal wrote:
> > > RE means a runtime error happened, not an issue of time since the judge 
> > > would've just said TLE (Time Limit Exceeded) if that was the case.
> > > 
> > > My program probably would've gotten a TLE for the hidden test set but it 
> > > shouldn't be an issue for the first set, where the highest valued prime 
> > > wouldn't exceed 10,000.
> > > 
> > > By the way Ralph, could you provide an example for the issue you stated? 
> > > Were you referring to cases like ABA, where the first two numbers in the 
> > > cipher text would be the same? I tried to account for that by including 
> > > the statement "decipher = decipher [::-1]"
> > 
> > First, your program prints something before the Case. This will make it 
> > fail.
> > 
> > Second, your program doesn't work on:
> > 
> > 1
> > 107 29
> > 15 15 15 15 21 49 77 143 221 323 437 667 899 1147 1517 1763 2021 2491 3127 
> > 3599 4087 4757 5183 5767 6557 7387 8633 9797 10403
> > 
> > It outputs "CACACBFDIEMFRGSHTJUKVLWNXOYPZQ", while the correct answer is 
> > "ABABACCDEFGHIJKLMNOPQRSTUVWXYZ"
> 
> 
> you can check my code that gives correct answer..still shows RE in codejam 
> unacceptable..
> 
> 
> def factors(n):
> ls=[]
> for i in range(2,n//2):
> if n%i==0:
> ls.append(i)
> break
> ls.append(n//i)
> 
> return ls
> 
> 
> t=int(input())
> #start_time = time.time()
> 
> for ix in range(1,t+1):
> n,l=map(int,input().rstrip().split(" "))
> s=str(input().rstrip())
> ls=list(s.split(" "))
> j=0
> dict={}
> al=[]
> nm=[]
> 
> for i in range(65,92):
> al.append(chr(i))
> fls=[]
> 
> 
> for i in ls:
> fls.append(factors(int(i)))
> 
> 
> l=factors(int(ls[0]))
> if int(ls[1])%l[0]==0:
> pv=l[0]
> ov=l[1]
> else:
> pv=l[1]
> ov=l[0]
> lll=[]
> lll.append(ov)
> lll.append(pv)
> for i in range(1,len(ls)):
> pv=int(ls[i])//pv
> lll.append(pv)
> 
> llp=sorted(list(set(lll)))
> 
> 
> 
> 
> llt=[]
> for i in lll:
> llt.append(al[llp.index(i)])
> 
> 
> strg="".join(llt)
> print("Case #{}: {}".format(ix,strg))
> #print("--- %s seconds ---" % (time.time() - start_time))

-- 
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/83c53cd8-3ca4-4de1-80aa-fe221ca33ca2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Can I expect any help from this community at all?

2019-04-12 Thread Xiongqi ZHANG
My 2 cents.

1. Keep in mind that we are not paid to answer your question, so no one should 
expect any prompt response. 

2. Most of the community are not expert, so we may not be able to answer your 
question if you are not providing enough information, such as 
language/version/platform etc.

3. Also keep in mind that reading someone else code isn't an easy thing either, 
most of the people (like me) will be frustrated when reading code without any 
documentation and the code is not self explanatory. Try to put comments in your 
code describing each line that does not do a trivial thing. Or try to write a 
summary of the approach you are using in plain English. Just don't assume that 
people can read your mind.

4. If your solution is not accepted, it is very likely that it is not correct. 
Producing the correct result in your local dev environment against your 
input/sample input doesn't mean your code is correct. Keep in mind that the 
platform will run much more complex test cases and/or extreme test cases and/or 
corner test cases. Just solving the usual test cases won't give you any credit 
at all. In rare cases, the platform did make mistake; they sometimes added test 
cases that are beyond the given input limit, or they forget to add some valid 
corner cases and let some incorrect solution passed, but this is not something 
you should worry about. Google has internal testers to make sure that the 
question/test data are well prepared.

5. I am quite active in this community, so if you do think you need any urgent 
help, you can try to reach me directly. I am familiar with C++/Java/Python.

-- 
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/2ebf4565-f3b6-48d3-b0c9-7a087d67995f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Solution Submission Error?

2019-04-11 Thread Xiongqi ZHANG
1. I downloaded his source
2. compiled it
3. Download the practice input
4. Run the executable with the practice input, generated the output
5. Upload the generated output as the practice output.
6. Get the accepted verdict from the UI.

在 2019年4月11日星期四 UTC-7下午1:03:57,Aviel Stein写道:
> On Monday, April 8, 2019 at 8:41:08 PM UTC-4, Xiongqi ZHANG wrote:
> > Works for me. Not sure why it does not work for you.
> > 
> > Please note that you should submit the generated output of the program, not 
> > the program itself.
> > 
> > The output should start with 'Case #1:' (without quotes).
> > 
> > 在 2019年4月8日星期一 UTC-7下午1:40:29,Aviel Stein写道:
> > > I tested by submitting Eryx's solution, accessible here (1), which got 
> > > the hightest score for that problem here (2) it gets a reject "Submission 
> > > for input A-large Rejected: Output file contains non-ASCII characters." 
> > > for both the large and small tests. 
> > > 
> > > 
> > > 1) https://www.go-hero.net/jam/17/name/Eryx
> > > 
> > > 2) https://code.google.com/codejam/contest/5304486/dashboard
> > > 
> > > All the best,
> > > 
> > > 
> > > Avi
> 
> Hi Xiongqi, I tried again and still got an error, can you tell me what you 
> did?

-- 
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/245686f4-4b00-4da7-98f1-ab3160732cfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Wrong answer on a Typescript solution

2019-04-10 Thread Xiongqi ZHANG
I think the problem is Number() cannot handle integer as large as 10^100

checks[0] = Number(num) - checks[1];


fyi. this copy will pass all the tests

/*
 * Marco Lackovic, Apr 2019
 * Google Code Jam, Qualification Round
 * Foregone Solution
 */

declare var require: any;
declare var process: any;
const readline = require("readline");
const rl = readline.createInterface({ input: process.stdin });

let i = 0;
rl.on("line", (num: string) => {
  if (i > 0) {
const [a, b] = solve(num);
console.log(`Case #${i}: ${a} ${b}`);
  }
  i++;
});

const solve = (num: string): string[] => {
  const checks = new Array(2);
  const numAsArrayOfDigits = num.split("").map(Number);
  checks[1] = numAsArrayOfDigits
  .map((d: Number) => (d == 4 ? 2 : 0))
  .map(String)
  .join("");
  checks[0] = numAsArrayOfDigits
  .map((d: Number) => (d == 4 ? 2 : d))
  .map(String)
  .join("");
  return checks;
};

在 2019年4月10日星期三 UTC-7下午3:31:04,Marco Lackovic写道:
> Can anyone spot where the problem is?
> 
> https://github.com/lackovic/codejam/blob/master/2019-typescript/src/QualificationRound/ForegoneSolution.ts

-- 
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/76e94cce-e7a2-42af-81b2-a261a38465c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Solution Submission Error?

2019-04-08 Thread Xiongqi ZHANG
Works for me. Not sure why it does not work for you.

Please note that you should submit the generated output of the program, not the 
program itself.

The output should start with 'Case #1:' (without quotes).

在 2019年4月8日星期一 UTC-7下午1:40:29,Aviel Stein写道:
> I tested by submitting Eryx's solution, accessible here (1), which got the 
> hightest score for that problem here (2) it gets a reject "Submission for 
> input A-large Rejected: Output file contains non-ASCII characters." for both 
> the large and small tests. 
> 
> 
> 1) https://www.go-hero.net/jam/17/name/Eryx
> 
> 2) https://code.google.com/codejam/contest/5304486/dashboard
> 
> All the best,
> 
> 
> Avi

-- 
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/41a7864c-0fcf-43ea-b328-7432413e4bab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Anybody has a working C# solution for Cryptopangrams?

2019-04-08 Thread Xiongqi ZHANG
Apparently this is not for the problem Cryptopangrams.

I am not C# expert, but I guess it is because adding a char to the end of a 
string is not constant time operation. Try using StringBuilder instead.

The following code will pass.


using System; 
using System.Collections.Generic; 
using System.IO; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

namespace Problem1 
{ 
class Program 
{ 
static void Main(string[] args) 
{ 

string numCases = Console.ReadLine(); 
int n = Int32.Parse(numCases.Trim()); 

for (int i = 0; i < n; i++) 
{ 

int sizeMaze = Int32.Parse(Console.ReadLine()); 
string pathEnemy = Console.ReadLine(); 
StringBuilder sb = new StringBuilder("", sizeMaze);
for (int j = 0; j < pathEnemy.Length; j++) 
{ 
if (pathEnemy[j] == 'S') sb.Append("E"); 
else sb.Append("S");
} 

Console.WriteLine("Case #" + (i + 1) + ": " + sb.ToString()); 
} 
} 
} 
} 

在 2019年4月8日星期一 UTC-7下午1:40:47,Peter Chikov写道:
> My solution follows the analysis and still times out(TLE).
> 
> using System;
> using System.Collections.Generic;
> using System.IO;
> using System.Linq;
> using System.Text;
> using System.Threading.Tasks;
> 
> namespace Problem1
> {
> class Program
> {
> static void Main(string[] args)
> {
> 
> string numCases = Console.ReadLine();
> int n = Int32.Parse(numCases.Trim());
> 
> for (int i = 0; i < n; i++)
> {
> 
> int sizeMaze = Int32.Parse(Console.ReadLine());
> string pathEnemy = Console.ReadLine();
> string path = "";
> for (int j = 0; j < pathEnemy.Length; j++)
> {
> if (pathEnemy[j] == 'S') path += 'E';
> else path += 'S';
> }
> 
> Console.WriteLine("Case #" + (i + 1) + ": " + path);
> }
> }
> }
> }

-- 
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/3fbea297-d74a-42e6-88ce-0d45855bc865%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: what is my mistake in cryptopangrams solution

2019-04-07 Thread Xiongqi ZHANG
p[0] and p[1] could be the same.
In this case, gcd() would not give you what you want.

在 2019年4月7日星期日 UTC-7下午2:20:53,ami...@gmail.com写道:
> def gcd(a, b):
>   if b == 0:
> return a
>   return gcd(b, a % b)
> 
> def solve():
>   _, l = map(int, input().split())
>   p = [int(i) for i in input().split()]
>   
>   pr = gcd(p[0], p[1])
> 
>   vals = []
>   vals.append(p[0] / pr)
>   vals.append(pr)
>   vals.append(p[1] / pr)
> 
>   for i in range(2, l):
> vals.append(p[i] / vals[i])
> 
>   prs = list(sorted(set(vals)))
>   
>   return ''.join([chr(65 + prs.index(i)) for i in vals])
> 
> for t in range(1, 1 + int(input())):
>   print('Case #{}: {}'.format(t, solve()))

-- 
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/3ad1738a-1f47-495a-bc87-f91b8afde978%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Question 3 runtime error

2019-04-07 Thread Xiongqi ZHANG
Also, not sure if it is intended, you removed 2 from the prime list.


在 2019年4月7日星期日 UTC-7下午1:59:29,Xiongqi ZHANG写道:
> When you work on the first value, you didn't check the order of prime1 and 
> prime2.
> 
> So the first two characters in the result could be swapped.
> 
> 在 2019年4月7日星期日 UTC-7上午6:24:19,Ronan Burke写道:
> > Hey,
> > I noticed lots of people were getting runtime errors in question 3 for the 
> > proper submission (not the sample input) as that seemed to be the main Q 
> > in the sidebar. I was using C# and I encountered the same problem.
> > 
> > I'm kind of clueless as to what caused it as there is no stack trace when 
> > submitting. This was my attempt:
> > https://gist.github.com/BurkusCat/3afe80dc877cb78184059197b609127b
> > (I had to add line 18 to make sure I could read in more than 254 
> > characters, I feel like that may have been a runtime error people would 
> > have encountered with some of the bigger inputs?)
> > 
> > I constructed as best of a test case as I could just to make sure I could 
> > deal with the bigger inputs:
> > 2
> > 1 100
> > 95413823 95550589 95726647 95824517 95981173 96177233 96314587 96491293 
> > 96648557 96746887 96923989 97101307 97180163 97318189 97555093 97713221 
> > 97891187 98089207 98307161 98525467 98604899 98724071 98903009 99161683 
> > 99400891 99400891 99400891 99400891 99400891 99400891 99400891 99400891 
> > 99400891 99400891 99400891 99400891 99400891 99400891 99400891 99400891 
> > 99400891 99400891 99400891 99400891 99400891 99400891 99400891 99400891 
> > 99400891 99400891 99400891 99400891 99400891 99400891 99400891 99400891 
> > 99400891 99400891 99400891 99400891 99400891 99400891 99400891 99400891 
> > 99400891 99400891 99400891 99400891 99400891 99400891 99400891 99400891 
> > 99400891 99400891 99400891 99400891 99400891 99400891 99400891 99400891 
> > 99400891 99400891 99400891 99400891 99400891 99400891 99400891 99400891 
> > 99400891 99400891 99400891 99400891 99400891 99400891 99400891 99400891 
> > 99400891 99400891 99400891 99400891
> > 
> > ...and it seemed to work fine. Any help would be much appreciated as I'm at 
> > a bit of a loss and it would be nice to know where I went wrong :)
> > 
> > Thanks,
> > Ronan

-- 
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/a00c77cf-90ae-4450-ac4c-7f4ef63b218b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Scala support is an illusion

2019-04-06 Thread Xiongqi ZHANG
would be great if you can also share the code you used :)

meir  于2019年4月6日周六 下午10:22写道:

> I was happy to see Scala was added to the supported languages. It's my
> language of choice and writing in a language I don't use daily not only
> slows me down it isn't as fun.
>
> I was unable to use Scala at all in the qualification round. I wrote short
> O(input length) solutions for the first two problems and they both timed
> out. Presumably due to extended compilation time. Locally each compiled in
> less than 2 seconds wall time. And less than 4 cpu seconds.
>
> Scala is actually a fairly speedy language at runtime. But if you setup
> the environment and time limits so that essentially any Scala program will
> use most if not all it's time budget compiling it means Scala isn't
> actually supported.
>
> Time limits in the 10 second vacinity beg for compilation or warm up
> issues. The 4-8 minute range was far better and these could always be
> neglected.
>
> I liked the pre 2018 platform better.
>
> Please support Scala for real!
> Significant time budget, dedicated compile budget or any other solution
> which will make it a real option.
>
> --
> 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/25254fe4-6acc-4ee1-b907-2e171eb091bf%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/CAGDEU-JE5VN%3D9w09Ho8-K9paM_ODM-tgpObm%2B2KphhxksP0Ywg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Kickstart 2019 round A Problem 2

2019-04-02 Thread Xiongqi ZHANG
More explanation here.

Let's look at a delivery office with distance 1,

it will cover the following map

010
111
010

you can notice that the max(i+j) and max(i-j) will have the same odd/even 
property no matter how you place this office in the map.

On the other hand,

00
00

cannot be covered by a new office with distance 1, no matter where you put the 
new office at.
But the max(i+j) - min(i+j) == 2 and max(i-j) - min(i-j) == 2
This is a good example of a false positive.
It is also easy to verify that max(i+j) and max(i-j) should be one odd, one 
even. They can't be both even or odd.


在 2019年4月2日星期二 UTC-7下午5:00:21,Xiongqi ZHANG写道:
> FYI. https://ideone.com/7xQxtR here is a copy of your code (modified) passing 
> the test.
> 
> 在 2019年4月2日星期二 UTC-7下午4:55:36,Xiongqi ZHANG写道:
> > Your solution couldn't handle this case correctly.
> > 
> > 1
> > 4 4
> > 1001
> > 
> > 
> > 1001
> > 
> > Your statement
> > > if max(i+j)-min(i+j)<=2*dist and max(i-j)-min(i-j)<=2*dist, then I judge 
> > > the distance dist achievable.
> > is not correct.
> > 
> > The correct statement should be
> > 
> > this distance is achievable if
> > 1. max(i + j) - min(i + j) < 2 * dist and max(i - j) - min(i - j) <= 2 * 
> > dist
> > or
> > 2. max(i + j) - min(i + j) <= 2 * dist and max(i - j) - min(i - j) < 2 * 
> > dist
> > or
> > 3. max(i + j) - min(i + j) == 2 * dist and max(i - j) - min(i - j) == 2 * 
> > dist and max(i + j) + max(i - j) is even.
> > 
> > 
> > 
> > 在 2019年4月2日星期二 UTC-7下午3:22:46,Yupeng Gu写道:
> > > For the problem Parcels in this round, can someone tell me why I'm still 
> > > getting wrong answer?
> > > 
> > > My solution is firstly doing BFS from the squares with value 1, then 
> > > doing binary search for the target distance. Within the binary search, I 
> > > loop through the squares. If the original distance of the square (i,j) is 
> > > greater than the assumed distance, I pick the square to see its i+j and 
> > > i-j value. After checking all squares, if max(i+j)-min(i+j)<=2*dist and 
> > > max(i-j)-min(i-j)<=2*dist, then I judge the distance dist achievable.
> > > 
> > > My code is as following:
> > > 
> > > #include
> > > using namespace std;
> > > 
> > > int main(){
> > >   int dx[4] = {0,0,1,-1},dy[4] = {1,-1,0,0};
> > >   int tt;cin>>tt;
> > >   for(int t=1;t<=tt;t++){
> > >   int r,c;cin>>r>>c;
> > >   vector initial;
> > >   for(int i=0;i > >   string row;cin>>row;
> > >   initial.push_back(row);
> > >   }
> > >   vector > dist;
> > >   queue > q;
> > >   for(int i=0;i > >   vector row;
> > >   for(int j=0;j > >   if(initial[i][j]=='1'){
> > >   row.push_back(0);
> > >   q.push(make_pair(i,j));
> > >   }else row.push_back(INT_MAX);
> > >   }
> > >   dist.push_back(row);
> > >   }
> > >   int max_dist=0;
> > >   while(!q.empty()){
> > >   int x = q.front().first,y = q.front().second;
> > >   q.pop();
> > >   max_dist = max(max_dist,dist[x][y]);
> > >   for(int i=0;i<4;i++){
> > >   int xx = x+dx[i],yy = y+dy[i];
> > >   if(xx>=0 && xx=0 && yy > >   if(dist[xx][yy]>dist[x][y]+1){
> > >   dist[xx][yy] = dist[x][y]+1;
> > >   q.push(make_pair(xx,yy));
> > >   }
> > >   }
> > >   }
> > >   }
> > >   int lower=-1,upper=max_dist;
> > >   while(upper-lower>1){
> > >   int mid = (upper+lower)/2;
> > >   int 
> > > ipjmax=-r-c-1,ipjmin=r+c+1,imjmax=-r-c-1,imjmin=r+c+1;
> > >   for(int i=0;i > >   for(int j=0;j > >   if(dist[i][j]>mid){
> > >   ipjmin = min(i+j,ipjmin

[gcj] Re: Kickstart 2019 round A Problem 2

2019-04-02 Thread Xiongqi ZHANG
FYI. https://ideone.com/7xQxtR here is a copy of your code (modified) passing 
the test.

在 2019年4月2日星期二 UTC-7下午4:55:36,Xiongqi ZHANG写道:
> Your solution couldn't handle this case correctly.
> 
> 1
> 4 4
> 1001
> 
> 
> 1001
> 
> Your statement
> > if max(i+j)-min(i+j)<=2*dist and max(i-j)-min(i-j)<=2*dist, then I judge 
> > the distance dist achievable.
> is not correct.
> 
> The correct statement should be
> 
> this distance is achievable if
> 1. max(i + j) - min(i + j) < 2 * dist and max(i - j) - min(i - j) <= 2 * dist
> or
> 2. max(i + j) - min(i + j) <= 2 * dist and max(i - j) - min(i - j) < 2 * dist
> or
> 3. max(i + j) - min(i + j) == 2 * dist and max(i - j) - min(i - j) == 2 * 
> dist and max(i + j) + max(i - j) is even.
> 
> 
> 
> 在 2019年4月2日星期二 UTC-7下午3:22:46,Yupeng Gu写道:
> > For the problem Parcels in this round, can someone tell me why I'm still 
> > getting wrong answer?
> > 
> > My solution is firstly doing BFS from the squares with value 1, then doing 
> > binary search for the target distance. Within the binary search, I loop 
> > through the squares. If the original distance of the square (i,j) is 
> > greater than the assumed distance, I pick the square to see its i+j and i-j 
> > value. After checking all squares, if max(i+j)-min(i+j)<=2*dist and 
> > max(i-j)-min(i-j)<=2*dist, then I judge the distance dist achievable.
> > 
> > My code is as following:
> > 
> > #include
> > using namespace std;
> > 
> > int main(){
> > int dx[4] = {0,0,1,-1},dy[4] = {1,-1,0,0};
> > int tt;cin>>tt;
> > for(int t=1;t<=tt;t++){
> > int r,c;cin>>r>>c;
> > vector initial;
> > for(int i=0;i > string row;cin>>row;
> > initial.push_back(row);
> > }
> > vector > dist;
> > queue > q;
> > for(int i=0;i > vector row;
> > for(int j=0;j > if(initial[i][j]=='1'){
> > row.push_back(0);
> > q.push(make_pair(i,j));
> > }else row.push_back(INT_MAX);
> > }
> > dist.push_back(row);
> > }
> > int max_dist=0;
> > while(!q.empty()){
> > int x = q.front().first,y = q.front().second;
> > q.pop();
> > max_dist = max(max_dist,dist[x][y]);
> > for(int i=0;i<4;i++){
> > int xx = x+dx[i],yy = y+dy[i];
> > if(xx>=0 && xx=0 && yy > if(dist[xx][yy]>dist[x][y]+1){
> > dist[xx][yy] = dist[x][y]+1;
> > q.push(make_pair(xx,yy));
> > }
> > }
> > }
> > }
> > int lower=-1,upper=max_dist;
> > while(upper-lower>1){
> > int mid = (upper+lower)/2;
> > int 
> > ipjmax=-r-c-1,ipjmin=r+c+1,imjmax=-r-c-1,imjmin=r+c+1;
> > for(int i=0;i > for(int j=0;j > if(dist[i][j]>mid){
> > ipjmin = min(i+j,ipjmin);
> > ipjmax = max(i+j,ipjmax);
> > imjmin = min(i-j,imjmin);
> > imjmax = max(i-j,imjmax);
> > }
> > }
> > }
> > if(((ipjmax-ipjmin)<=2*mid) && 
> > ((imjmax-imjmin)<=2*mid))upper = mid;
> > else lower = mid;
> > }
> > cout<<"Case #"< > }
> > return 0;
> > }

-- 
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/9ed847b7-e8ec-428c-a218-2518873acce4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Kickstart 2019 round A Problem 2

2019-04-02 Thread Xiongqi ZHANG
Your solution couldn't handle this case correctly.

1
4 4
1001


1001

Your statement
> if max(i+j)-min(i+j)<=2*dist and max(i-j)-min(i-j)<=2*dist, then I judge the 
> distance dist achievable.
is not correct.

The correct statement should be

this distance is achievable if
1. max(i + j) - min(i + j) < 2 * dist and max(i - j) - min(i - j) <= 2 * dist
or
2. max(i + j) - min(i + j) <= 2 * dist and max(i - j) - min(i - j) < 2 * dist
or
3. max(i + j) - min(i + j) == 2 * dist and max(i - j) - min(i - j) == 2 * dist 
and max(i + j) + max(i - j) is even.



在 2019年4月2日星期二 UTC-7下午3:22:46,Yupeng Gu写道:
> For the problem Parcels in this round, can someone tell me why I'm still 
> getting wrong answer?
> 
> My solution is firstly doing BFS from the squares with value 1, then doing 
> binary search for the target distance. Within the binary search, I loop 
> through the squares. If the original distance of the square (i,j) is greater 
> than the assumed distance, I pick the square to see its i+j and i-j value. 
> After checking all squares, if max(i+j)-min(i+j)<=2*dist and 
> max(i-j)-min(i-j)<=2*dist, then I judge the distance dist achievable.
> 
> My code is as following:
> 
> #include
> using namespace std;
> 
> int main(){
>   int dx[4] = {0,0,1,-1},dy[4] = {1,-1,0,0};
>   int tt;cin>>tt;
>   for(int t=1;t<=tt;t++){
>   int r,c;cin>>r>>c;
>   vector initial;
>   for(int i=0;i   string row;cin>>row;
>   initial.push_back(row);
>   }
>   vector > dist;
>   queue > q;
>   for(int i=0;i   vector row;
>   for(int j=0;j   if(initial[i][j]=='1'){
>   row.push_back(0);
>   q.push(make_pair(i,j));
>   }else row.push_back(INT_MAX);
>   }
>   dist.push_back(row);
>   }
>   int max_dist=0;
>   while(!q.empty()){
>   int x = q.front().first,y = q.front().second;
>   q.pop();
>   max_dist = max(max_dist,dist[x][y]);
>   for(int i=0;i<4;i++){
>   int xx = x+dx[i],yy = y+dy[i];
>   if(xx>=0 && xx=0 && yy   if(dist[xx][yy]>dist[x][y]+1){
>   dist[xx][yy] = dist[x][y]+1;
>   q.push(make_pair(xx,yy));
>   }
>   }
>   }
>   }
>   int lower=-1,upper=max_dist;
>   while(upper-lower>1){
>   int mid = (upper+lower)/2;
>   int 
> ipjmax=-r-c-1,ipjmin=r+c+1,imjmax=-r-c-1,imjmin=r+c+1;
>   for(int i=0;i   for(int j=0;j   if(dist[i][j]>mid){
>   ipjmin = min(i+j,ipjmin);
>   ipjmax = max(i+j,ipjmax);
>   imjmin = min(i-j,imjmin);
>   imjmax = max(i-j,imjmax);
>   }
>   }
>   }
>   if(((ipjmax-ipjmin)<=2*mid) && 
> ((imjmax-imjmin)<=2*mid))upper = mid;
>   else lower = mid;
>   }
>   cout<<"Case #"<   }
>   return 0;
> }

-- 
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/2572d88a-d971-4c20-9c7c-fb4514192ce9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Kickstart Round A solution

2019-03-26 Thread Xiongqi ZHANG
FYI

t = int(input())
for case in range(t):
[n, p] = list(map(int, input().split()))
s = list(map(int, input().split()))
ans = 0
if n == p:
m = max(s)
for i in range(p):
if s[i] < m:
ans += (m - s[i])
else:
s = sorted(s)
temp = 0
for i in range(p-1):
temp += (s[p-1] - s[i])
ans = temp
for i in range(1, n-p+1):
prev = s[i+p-2] - s[i-1]
next = ((p-1) * (s[i+p-1] - s[i+p-2]))
temp -= prev
temp += next
ans = min(ans, temp)

print("Case #{}: {}".format(case+1, ans))

> Can anybody share the solutions of the problem?
> 
> Or help me debug mine?
> my code is passing the given test cases but showing WA on submission
> 
> (Training)
> 
> t = int(input())
> for case in range(t):
> [n, p] = list(map(int, input().split()))
> s = list(map(int, input().split()))
> ans = 0
> if n == p:
> m = max(s)
> for i in range(p):
> if s[i] < m:
> ans += (m - s[i])
> else:
> s = sorted(s)
> temp = 0
> for i in range(p-1):
> temp += (s[p-1] - s[i])
> for i in range(1, n-p+1):
> prev = s[i+p-2] - s[i-1]
> next = ((p-1) * (s[i+p-1] - s[i+p-2]))
> if next < prev:
> temp -= prev
> temp += next
> ans = temp
> 
> print("Case #{}: {}".format(case+1, ans))

-- 
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/4fc38d8b-9cbd-4501-b354-f53212eeaa58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] 2018 KickStart Round G Product Triplets

2019-03-25 Thread Xiongqi ZHANG
 if (ls[i]*ls[j]) in ls[j+1:]:
count+=1

I think you should add the number of occurrence instead of just 1
Also, isn't this solution too slow for large data set?


Ho Wei Hong  于2019年3月25日周一 上午7:22写道:

> Sorry to disturb this group again.
>
> But i can't seem to figure out where i got wrong. I feed in a few test
> case and everything works, but the checker seems to say WA(Wrong Answer)
>
>
> Hope somebody can point me to the right direction again. Thank you
>
>
> https://codingcompetitions.withgoogle.com/kickstart/round/00051066/00051187
>
> def sol(ls):
> ls.sort()
> count = 0
> if ls[1]==0:
> temp = ls.count(0)
> if temp>=3:
> #number of 0 Choose 3
> count+=temp*(temp-1)*(temp-2)//6
> #(Temp choose 2 times number of non-zeroes)
> count+= temp*(temp-1)//2*(len(ls)-temp)
>
> for i in range(len(ls)-2):
> if ls[i]==0:
> continue #ignore zeroes
> for j in range(i+1,len(ls)-1):
> if (ls[i]*ls[j]) in ls[j+1:]:
> count+=1
> return count
>
> def main():
> for i in range(int(input())):
> a = int(input())
> y = input()
> ls= [int(x) for x in y.split(' ')]
> c = sol(ls)
> print("Case #{}: {}".format(i+1, c))
> return
>
> main()
>
> --
> 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/6a0352be-f38b-4539-be80-265f50c41d56%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/CAGDEU-Js%2BuJ1_cndJBTGHY0hNvtEaVHHPb0%3DP7FHrx%2BUko8Ngw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Re: code jam women platform input WA test case skipped

2019-02-16 Thread Xiongqi ZHANG
I think what Guessing want is a button that you can use to run your code 
against the sample input and optionally check the correctness of the output 
against sample (or at least formatting).

This may not work well thought if multiple answers are acceptable, i.e. need 
special judge. 



> Hi,
> 
> 
> 
> What do you mean "you are not able to test your code". You should be, you are 
> just not expected to be able to do it on real data, you have to provide your 
> own data, and results may depend on data, of course. Regarding visibility, 
> you can see our FAQ, but the definition of visibility only regards to access 
> to the judgement and scoring: judgement of visible test will be shown to you 
> before the end of the round, while judgement of hidden tests will be withheld 
> until the round is over. For neither of them we show the test data or the 
> actual output your code gave, only for test runs with user-provided data.
> 
> 
> I hope this clarifies things. I suggest checking the FAQ for more precise 
> definitions of Visible/Hidden test sets and test runs.
> 
> 
> Best,
> Pablo
> 
> 
> On Sat, Feb 16, 2019 at 3:43 AM Guessing  wrote:
> seems odd that I am not able to test my code on the contest website before 
> submitting. I mean of course I can test it on my computer but I rather test 
> it using the platform to avoid issues where I have an extra space printed put 
> for example and I don't see it because it's easy to not see an extra space 
> when using your eyes.
> 
> 
> 
> Also, with the new platform I am not able to see any of the tests - I am 
> talking about the non hidden (visible) ones. Is there something I missed?
> 
> 
> 
> Thanks for your reply!
> 
> 
> 
> On Friday, February 15, 2019 at 11:09:00 PM UTC+1, Pablo Heiber wrote:
> 
> > Hi,
> 
> > 
> 
> > 
> 
> > Notice that the inputs for test runs and real submissions are different, so 
> > it's not unlikely to obtain different results. Additionally, the time limit 
> > might be different (test runs have a 10 second time limit at present, while 
> > real runs depend on the problem), which can also lead to different 
> > outcomes, especially for problems imported from our previous system which 
> > tend to have higher time limits.
> 
> > 
> 
> > 
> 
> > Hope this helps.
> 
> > 
> 
> > 
> 
> > Best,
> 
> > Pablo
> 
> > 
> 
> > 
> 
> > On Fri, Feb 15, 2019 at 12:18 PM Guessing  wrote:
> 
> > I had every test fail but when I submit the code, I get 2 green V saying I 
> > solved both the small and large data set. Tried writing google about it and 
> > they kind of ignored it and just sent me to the FAQ. 
> 
> > 
> 
> > Is this what you have been experiencing? 
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > On Tuesday, February 12, 2019 at 10:44:26 PM UTC+1, Ionelia Buzatu wrote:
> 
> > 
> 
> > > Why it says  "WA test case skipped" when I runt it? It's fine on my 
> > > machine. Am I not parsing the input correctly? What's wrong here?
> 
> > 
> 
> > > 
> 
> > 
> 
> > > this is from 2018 Burger Optimization exercises. It gives me the same 
> > > error for all exercises.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > from itertools import permutations
> 
> > 
> 
> > > 
> 
> > 
> 
> > > def burger():
> 
> > 
> 
> > >     output = {}
> 
> > 
> 
> > >     for repeat in range(1, int(input())+ 1):
> 
> > 
> 
> > >         ingredients = int(input())
> 
> > 
> 
> > >         distance_ingredients = [int(x) for x in input().split()]
> 
> > 
> 
> > >         totpermutations = permutations(distance_ingredients)
> 
> > 
> 
> > >         value = 99
> 
> > 
> 
> > >         if len(distance_ingredients) > 4:
> 
> > 
> 
> > >             for distance in totpermutations:
> 
> > 
> 
> > >                 value = min(value, (distance[0] - 0) ** 2 + (distance[1] 
> > >- 1) ** 2 + sum(
> 
> > 
> 
> > >                     [(i - 2) ** 2 for i in distance[2:-2]]) + 
> > >(distance[-2] - 1) ** 2 + (distance[-1] - 0) ** 2)
> 
> > 
> 
> > >         if len(distance_ingredients) == 4:
> 
> > 
> 
> > >             for distance in totpermutations:
> 
> > 
> 
> > >                 value = min(value, (distance[0] - 0) ** 2 + (distance[1] 
> > >- 1) ** 2 + (distance[-2] - 1) ** 2 + (
> 
> > 
> 
> > >                             distance[-1] - 0) ** 2)
> 
> > 
> 
> > >         if len(distance_ingredients) == 3:
> 
> > 
> 
> > >             for distance in totpermutations:
> 
> > 
> 
> > >                 value = min(value, (distance[0] - 0) ** 2 + (distance[1] 
> > >- 1) ** 2 + (distance[-1] - 0) ** 2)
> 
> > 
> 
> > >         if len(distance_ingredients) == 2:
> 
> > 
> 
> > >             for distance in totpermutations:
> 
> > 
> 
> > >                 value = min(value, (distance[0] - 0) ** 2 + (distance[1] 
> > >- 1) ** 2)
> 
> > 
> 
> > >         if len(distance_ingredients) == 1:
> 
> > 
> 
> > >             for distance in totpermutations:
> 
> > 
> 
> > >                 value = min(value, (distance[0] - 0) ** 2)
> 
> > 
> 
> > >         output[repeat] = "Case 

Re: [gcj] code jam women platform input. PLEASE HELP ME

2019-02-12 Thread Xiongqi ZHANG
1. Your solution is way too slow. Your solution try every permutation,
which will timeout for large K
2. You seems to misunderstood the problem. Try the following test.

Input
1
8
0 0 1 1 2 2 3 3

Output
Case #1: 0

Ionelia Buzatu  于2019年2月12日周二 下午1:44写道:

> Why the hack it gives me always   "wrong answer test set skipped"?
>
> It works on my local machine but on the server, it seems the answer is
> wrong, why??
> Am I not considering the input?
>
> look this is my code for 2018 Burger Optimization problem
>
> from itertools import permutations
>
> def burger():
> output = {}
> for repeat in range(1, int(input())+ 1):
> ingredients = int(input())
> distance_ingredients = [int(x) for x in input().split()]
> totpermutations = permutations(distance_ingredients)
> value = 99
> if len(distance_ingredients) > 4:
> for distance in totpermutations:
> value = min(value, (distance[0] - 0) ** 2 + (distance[1] -
> 1) ** 2 + sum(
> [(i - 2) ** 2 for i in distance[2:-2]]) +
> (distance[-2] - 1) ** 2 + (distance[-1] - 0) ** 2)
> if len(distance_ingredients) == 4:
> for distance in totpermutations:
> value = min(value, (distance[0] - 0) ** 2 + (distance[1] -
> 1) ** 2 + (distance[-2] - 1) ** 2 + (
> distance[-1] - 0) ** 2)
> if len(distance_ingredients) == 3:
> for distance in totpermutations:
> value = min(value, (distance[0] - 0) ** 2 + (distance[1] -
> 1) ** 2 + (distance[-1] - 0) ** 2)
> if len(distance_ingredients) == 2:
> for distance in totpermutations:
> value = min(value, (distance[0] - 0) ** 2 + (distance[1] -
> 1) ** 2)
> if len(distance_ingredients) == 1:
> for distance in totpermutations:
> value = min(value, (distance[0] - 0) ** 2)
> output[repeat] = "Case #{}: {}".format(repeat, value)
> # print("Case #{}: {}".format(repeat, value))
> return "\n".join(output.values())
>
> print(burger())
>
>
> Why the server doesn't like any of my submission, also others exercises,
> same thing.
>
> --
> 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/0cd30879-3358-49c1-aad3-473f528d284a%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/CAGDEU-K5K%2BVUvNcgO4BEjZXe8J_Ac%3DOS2rVnhjbp95x-KcdFZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Confusing Runtime Error for Round 1B - Rounding Error (Codejam 2018)

2018-12-19 Thread Xiongqi ZHANG
Try to not use floating point to solve this problem.

XYZT  于2018年12月19日周三 下午7:40写道:

> Hi,
>
> I am trying to write a solution for "Rounding Error" in Round 1B of
> Codejam 2018 using Python 3 and I am getting a strange "Runtime Error"
> message which I can't seem to replicate locally.
>
> I've tried several different inputs and failed to generate a runtime error.
>
> Here is my code:
>
> # Codejam 2018, Round 1B: Rounding Error
>
> from math import floor
>
> def round_half_up(x):
> """Rounding to nearest integer with tie-breaker rounding up."""
> return floor(x + 0.5)
>
> def round_up_set(N):
> """Returns set of vote counts that round UP."""
> return set([i for i in range(1, N + 1)
> if round_half_up(100*i/N) != floor(100*i/N)])
>
> def get_percentage(num_voters, lang_votes):
> """Gets total percentage given list of vote counts and total voters."""
> return sum([round_half_up(100*i/num_voters) for i in lang_votes])
>
> def get_max_percentage(num_voters, lang_votes):
> """Find max sum of votes when rounding percentages of votes."""
> voters_left = num_voters - sum(lang_votes)
> round_up_votes = round_up_set(num_voters)
>
> # If there exist any values that will round up
> if len(round_up_votes) > 0:
> min_votes = min(round_up_votes)
>
> for i, votes in enumerate(lang_votes):
> # If vote count is currently not rounding up, add more votes
> if votes not in round_up_votes:
> extra_votes = min([i for i in round_up_votes
>if i > votes]) - votes
>
> if extra_votes < min_votes and extra_votes <= voters_left:
> lang_votes[i] += extra_votes
> voters_left -= extra_votes
>
> # Keep adding new languages with minimum votes for rounding up
> while voters_left >= min_votes:
> lang_votes.append(min_votes)
> voters_left -= min_votes
>
> # If there are voters left, get them all to vote on a new language
> if voters_left > 0:
> lang_votes.append(voters_left)
>
> return get_percentage(num_voters, lang_votes)
>
> # I/O Code
> num_cases = int(input())
>
> for case in range(1, num_cases + 1):
> num_voters, num_lang = [int(i) for i in input().split()]
> lang_votes = [int(i) for i in input().split()]
>
> max_percentage = get_max_percentage(num_voters, lang_votes)
> print("Case #{}: {}".format(case, max_percentage))
>
> --
> 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/ac2a2cba-51ab-48d0-94fc-0f10e57c4d6b%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/CAGDEU-JPLdGJUHsCFQ22VDp-Lh02g2GKZjnXS8mJuPHrZ6-gdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Kickstart Round F Problem A Common Anagrams analysis

2018-10-01 Thread Xiongqi ZHANG
You're right.

Given the time restraint, the solution for small data set works fine for large 
data set.

It is ok to have multiple working solution for small and large.
Don't think too much about it.

-- 
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/70d7d12d-7964-4a9a-8b7c-479d469f974a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Re: Can someone please tell me what is wrong with my code

2018-09-19 Thread Xiongqi ZHANG
Jashanpreet is right.

*h* is the counter for the number of yogurts you had for a day.
*max* is the counter for the total number of yogurts you had.
*h* should be incremented when and only when *max* is incremented.



Jashanpreet Singh 于2018年9月19日周三 下午1:38写道:

> In the code snippet:
>* for(int h=1;h<=k;h++)*
>
>
>
>
> *{   if(index==n){break;}
>   if(g
> *else{index++;} //break;REMOVED
>   }*
>
> `h` should be incremented only when the loop enters the second `if` block.
>
> On Thu, Sep 20, 2018 at 1:36 AM Anamika Mathur 
> wrote:
>
>> Thanku so much again for taking the time and effort.
>>
>> I think to correct my solution I just need to remove the break statement
>> in the else condition to continue checking the next yogurt till full.
>>
>> I did do that and am still getting incorrect answer.
>>
>> import java.io.*;
>> import java.lang.*;
>> import java.util.Scanner;
>> import java.util.Arrays;
>> class A
>> {
>> public static void main(String args[])throws IOException
>> {
>>
>> Scanner input = new Scanner(System.in);
>>  int t = input.nextInt();
>> int x;
>> for(x=1;x<=t;x++){
>>
>>  int n = input.nextInt();
>>  int k = input.nextInt();
>>int a[]=new int[n];
>>int i;
>>for(i=0;i>a[i] = input.nextInt();
>>Arrays.sort(a);
>>
>>int max=0,index=0;
>>for(int g=0;g>if(index==n){break;}
>>
>>  for(int h=1;h<=k;h++){
>>  if(index==n){break;}
>>
>> if(g>
>>/* You are trying to do greedy for picking yogurt everyday
>>
>> Your algorithm:
>>  1. Sort all yogurt by their expiry day.
>>  2. Each day, until I am full, I check the next yogurt
>>  2.1 If the yogurt is not expired, I eat them
>>   2.2 If the yogurt is expired, I throw it away and end this
>> day.
>>
>>  The mistakes happen at 2.2
>>Instead of ending this day, you should keep checking
>> the next yogurt until you are full.*/
>>
>> else{index++;} //break;REMOVED
>> }
>>
>> }
>>System.out.println("Case #"+x+": "+max);
>> }
>>
>> }
>> }
>>
>>
>>
>> --
>> 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/2ffde858-b1a2-4d83-b839-1cf7d16d8bef%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/CACmYGGQ_GcjUj8jRGS_nPUzo%2B26QgFS%3DFe1Q6KdCJv6PzvO-WQ%40mail.gmail.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/CAGDEU-JbY5ZYeev421FuzL1-NDmwh%3DD3Pt%2BsAiGONtKj53cuVg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Re: Can someone please tell me what is wrong with my code

2018-09-18 Thread Xiongqi ZHANG
You are trying to do greedy for picking yogurt everyday

Your algorithm:
1. Sort all yogurt by their expiry day.
2. Each day, until I am full, I check the next yogurt
2.1 If the yogurt is not expired, I eat them
2.2 If the yogurt is expired, I throw it away and end this day.

The mistakes happen at 2.2
Instead of ending this day, you should keep checking the next yogurt until
you are full.

Akshay Mittal 于2018年9月18日周二 上午7:49写道:

> just make sure you add comments and output statements saying what your
> trying to do.
> which might help others help you.
>
> --
> 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/222a4805-b60f-47cd-ad7e-227f2fb471ca%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/CAGDEU-%2BuKF0Ysn7yZcrXQ2b5bJ1Qv79RgNDbxvo58wdqg3d_jA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] 1A 2018 Bit Party - Runtime error

2018-08-16 Thread Xiongqi ZHANG
B is up to 10^9 and in your code, you have stuff like range(B + 1)
I believe this is the reason you get runtime error.

Eugene Yarmash 于2018年8月16日周四 上午6:35写道:

> My Python3 code solves the 1st test case, but gives a 'Runtime error' for
> the 2nd. What may be the reason for this?
>
> As for the algorithm, I try to find all the ways to partition bits among
> up to R cashiers.
>
>
> from itertools import chain, combinations, combinations_with_replacement
>
>
> class Cashier:
> __slots__ = ('max_bits', 'scan_time', 'packaging_time')
>
> def __init__(self, M, S, P):
> self.max_bits = M
> self.scan_time = S
> self.packaging_time = P
>
>
> def main():
> T = int(input())  # the number of test cases
>
> for case in range(1, T+1):
> R, B, C = map(int, input().split())  # robot shoppers, bits,
> cashiers
>
> cashiers = []
>
> for _ in range(C):
> M, S, P = map(int, input().split())  # max number of bits,
> scan time per bit, packaging time
> cashier = Cashier(M, S, P)
> cashiers.append(cashier)
>
> res = float('inf')
>
> for num_cashiers in range(1, R+1):
> for sel_cashiers in combinations(cashiers, num_cashiers):
> for bits_bars in combinations_with_replacement(range(B+1),
> num_cashiers-1):
> prev_bar = 0
> times = []
>
> for cashier, bar in zip(sel_cashiers, chain(bits_bars,
> (B,))):
> num_bits = bar - prev_bar
> prev_bar = bar
> if num_bits > cashier.max_bits:
> break
> times.append(num_bits*cashier.scan_time +
> cashier.packaging_time)
> else:
> time = max(times)
> if time < res:
> res = time
>
> print('Case #{}: {}'.format(case, res))
>
>
> main()
>
> --
> Regards,
>   Eugene
>
> --
> 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/914b7f44-b1d9-f6bf-44f4-06e145ae09f0%40gmail.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/CAGDEU-JB%3DTSoGX%3D5NGPUU5kv8V6OJ7fq%3DuO0y-kkmZmSAhx1eg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Kickstart Round D question A and B

2018-08-14 Thread Xiongqi ZHANG
For problem A
try the following test case

1
3 100 100
0 18 0 0 0 20 -19

Expect output:
Case #1: -1

DeAngelo 于2018年8月14日周二 上午7:27写道:

> On Tuesday, 14 August 2018 04:01:48 UTC+10, SHUBHAM KUMAR SHUKLA  wrote:
> > can please share code
>
> Sure
>
> This is problem A
>
> //package kickstart.Y18.RoundD.A;
>
> import java.util.Scanner;
>
> public class QuestionA {
> public static void main(String[] args) {
> Scanner keyboard = new Scanner(System.in);
> int t = keyboard.nextInt();
>
> keyboard.nextLine();
> int count = 1;
> while(t-- > 0) {
> String[] temp = keyboard.nextLine().split(" ");
> int n = Integer.parseInt(temp[0]);
> int o = Integer.parseInt(temp[1]);
> double d = Double.parseDouble(temp[2]);
>
> temp = keyboard.nextLine().split(" ");
> int x1 = Integer.parseInt(temp[0]);
> int x2 = Integer.parseInt(temp[1]);
> int a = Integer.parseInt(temp[2]);
> int b = Integer.parseInt(temp[3]);
> int c = Integer.parseInt(temp[4]);
> int m = Integer.parseInt(temp[5]);
> int l = Integer.parseInt(temp[6]);
>
> double[] candies = new double[n];
> double[] xArray = new double[n];
> double[] ss = new double[n];
> int[] oddCount = new int[n];
>
> xArray[0] = x1;
> candies[0] = x1 + l;
> oddCount[0] = !(candies[0] % 2 == 0) ? 1 : 0;
> ss[0] = candies[0];
>
> xArray[1] = x2;
> candies[1] = x2 + l;
> oddCount[1] = !(candies[1] % 2 == 0) ? oddCount[0] + 1 :
> oddCount[0];
> ss[1] = ss[0] + candies[1];
>
> for(int i = 2; i < n; i++) {
> xArray[i] = (a * xArray[i - 1] + b * xArray[i - 2] + c) %
> m;
> candies[i] = ((a * xArray[i - 1] + b * xArray[i - 2] + c)
> % m) + l;
> oddCount[i] = !(candies[i] % 2 == 0) ? oddCount[i - 1] + 1
> : oddCount[i - 1];
> ss[i] = ss[i - 1] + candies[i];
> }
>
> double max = -1 * Double.MAX_VALUE;
> double lastMax = max;
> int cursor = 0;
> int flag = 0;
> for(int i = 0; i < n; i++) {
> double localMax = lastMax;
> double curMax = lastMax;
> cursor = flag;
> int so = (i == 0) ? oddCount[cursor] : oddCount[cursor] -
> oddCount[i - 1];
>
> if(localMax > d) {
> localMax = -1 * Double.MAX_VALUE;
> cursor = i;
> so = (candies[i] % 2 == 0) ? 0 : 1;
> }
>
> if(localMax > max && so <= o) {
> max = localMax;
> curMax = localMax;
> if(cursor == i) {
> lastMax = -1 * Double.MAX_VALUE;
> } else {
> lastMax = curMax - candies[i];
> }
> }
>
> while(so <= o){
> localMax = (i == 0) ? ss[cursor] : ss[cursor] - ss[i -
> 1];
>
> if(localMax > d) {
> if(cursor == i) {
> lastMax = -1 * Double.MAX_VALUE;
> } else {
> lastMax = curMax - candies[i];
> }
> break;
> }
>
> if(localMax > max) {
> max = localMax;
> curMax = localMax;
> if(cursor == i) {
> lastMax = -1 * Double.MAX_VALUE;
> } else {
> lastMax = curMax - candies[i];
> }
> }
>
> if(cursor == n - 1) {
> break;
> } else {
> cursor++;
> }
>
> so = (i == 0) ? oddCount[cursor] : oddCount[cursor] -
> oddCount[i - 1];
> }
>
> if(cursor == i) {cursor++;}
> flag = cursor;
> }
>
> if(max == -1 * Double.MAX_VALUE) {
> System.out.printf("Case #%d: IMPOSSIBLE\n", count);
> } else {
> System.out.printf("Case #%d: %.0f\n", count, max);
> }
> count++;
> }
> }
>
> }
>
>
> This is problem B
>
> //package kickstart.Y18.RoundD.B;
>
> import java.util.Scanner;
> import java.util.ArrayList;
> import java.util.Set;
> import java.util.Map;
> import java.util.TreeMap;
> import java.util.HashMap;
> import javafx.util.Pair;
>
> public class QuestionB {
>
> public static void main(String[] args) {
> Scanner in = new Scanner(System.in);
> int t = 

Re: [gcj] Submissions practice doesn't work ?

2018-08-14 Thread Xiongqi ZHANG
My best guess is that you submitted the code instead of the output.
On Tue, Aug 14, 2018 at 9:26 AM Ruben Ruiz  wrote:

> Hello,
>
> Can someone help me out, I was practising doing the 2016 Code Jam Problem
> A. Counting Sheep (
> https://code.google.com/codejam/contest/6254486/dashboard ) and I m
> getting Submission for input A-small Rejected: Your output should start
> with 'Case #1: '
>
>  I ve even donwload and submit the Gennady Code from that year and it's
> still giving me that error message.
>
> Any way this is the code I'm trying to submit:
>
> t = int(input())
>
> for i in range(1, t + 1):
> n=input()
>
> if n == 0: print ("INSOMNIA")
>
> s = set()
> x = 0
> while len(s) < 10:
> x += n
> s.update(str(x))
>
> print("Case #{}: {}".format(str(i),str(x)))
>
>
> is it anyone getting that errror ?
>
>
> Thanks in advance
>
> --
> 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/7e70044b-756c-4c66-aa60-2626c46a2b95%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/CAGDEU-J44%3DTpynuAixdxME3KyRZwrxCcwVpRvg1AD3ageGVERw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Rounding Error - Wrong answer

2018-08-04 Thread Xiongqi ZHANG
There is nothing wrong in the code.
You simply need to avoid using floating points arithmetics.

Here is a reference on how to solve the problems with integers.

https://ideone.com/snAUxE


> My Python3 code produces the correct result for the sample input,
>   but gives 'Wrong answer' for the 1st test set. Can anyone give me
>   a hint of how to fix it?
> 
> As for the algorithm, I use a priority queue
> to give priority to percentages whose fractional part is as
> close as possible to
>   0.5 and don't touch percentages whose fractional part
> is already >= 0.5.
> 
> 
> 
>   
> 
> from
> heapq import heappop, heappush
> 
> 
> 
> 
> 
> def main():
> 
>     T = int(input())  # the number of test cases
> 
> 
> 
>     for case in range(1, T+1):
> 
>     total_people, num_languages = map(int,
> input().split())
> 
>     freq = map(int, input().split())
> 
> 
> 
>     percent_per_person = 100/total_people
> 
>     low_scores = []
> 
>     not_responded = total_people
> 
>     res = 0
> 
> 
> 
>     for f in freq:
> 
>     p = f*percent_per_person
> 
>     if 0 < p-int(p) < 0.5:
> 
>     heappush(low_scores, (-(p-int(p)), p))
> 
>     else:
> 
>     res += round(p)
> 
>     not_responded -= f
> 
> 
> 
>     while not_responded:
> 
>     try:
> 
>     diff, p = heappop(low_scores)
> 
>     except IndexError:
> 
>     p = 0
> 
> 
> 
>     p += percent_per_person
> 
> 
> 
>     if 0 < p-int(p) < 0.5:
> 
>     heappush(low_scores, (-(p-int(p)), p))
> 
>     else:
> 
>     res += round(p)
> 
>     not_responded -= 1
> 
> 
> 
>     res += sum(round(x[1]) for x in low_scores)
> 
> 
> 
>     print('Case #{}: {}'.format(case, res))
> 
> 
> 
> main()
> 
>   
> -- 
> Regards,
>   Eugene

-- 
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/eaf3bdc4-8af0-4a67-bc6b-09322a159d0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Can I use JavaScript in Google Code Jam KickStart??

2018-07-24 Thread Xiongqi ZHANG
Yes you can

Musicion 于2018年7月24日周二 上午9:09写道:

> Hey, I need help,
> Please tell me can I use JavaScript in Google code jam Kickstart
>
> --
> 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/34d0606d-f5c3-4616-bce7-5e0ba079ab1c%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/CAGDEU-LXLj%2BNs%3D%2BztCZUUfBAFnCekoML%2BKf6wCrpF_LS4maFdg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: transmutation - help understanding analysis

2018-05-21 Thread Xiongqi ZHANG
1. If metal x will be used somewhere else, there is no difference between "use 
it now and go for its ingredients later" and "use its ingredients now and use 
it later"; If metal x will NOT be used somewhere else, then use it now is a 
better solution; So no matter what, you should use it now and go for its 
ingredients after all metal x are used.

2. Until the first pass finished, you don't know which one is the limiting 
ingredient. How can you replace something that you don't know yet?

-- 
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/79eacfab-cecf-4f37-a64d-b16bfcd5d5ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Code Jam Round 2 is now closed!

2018-05-20 Thread Xiongqi ZHANG
I can't really make R < B all the time.

In my solution, dp[a][b][r] means the maximum set of pair(x, y) such that
sum(x) <= b
sum(y) <= r
and all x >= a

so
dp[a][b][r] = max {dp[a + 1][b - (j + 1) * a][r - j * (j + 1) / 2] + j + 1}
assuming that the set contains (a, 0) (a, 1) . (a, j)

which means, dp[a][b][r] is different from dp[a][r][b]

The answer is simply dp[0][b][r] given b and r

-- 
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/2bea892c-bf30-4a8b-8712-4259bf9c13d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Code Jam Round 2 is now closed!

2018-05-20 Thread Xiongqi ZHANG
Here is my successful python2 solution
https://paste.ubuntu.com/p/HcP7Cqb88x/

Even though solution exists, I still agree that we should either run codes
with pypy or has extended runtime for python solutions..

Chris Knott 于2018年5月20日周日 上午1:30写道:

> Does anyone have a successful Python solution for B that doesn't just
> include a precalculated array in the source?
>
> The solution they've described in the analysis doesn't seem remotely fast
> enough...?
>
> I really think Google need to consider either allowing Pypy as a platform,
> or just giving more running time to the slower languages.
>
> --
> 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/7efd55a5-19c6-421e-ae98-7c4b43085503%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/CAGDEU-%2BMKEAhA0eC6UFPJqHp9gkxwD-iU-TajqOKbh%3DchikRRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Re: Round 1B 2018 Rounding Error : proof that we must maximize the number of rounded up languages

2018-05-15 Thread Xiongqi ZHANG
Sorry, I messed up the samples.

I meant 100/N = 0.3%

1) if we give it to 5.4%, it becomes 5.7%, so it changes from 0.4% loss to 0.3% 
gain;

2) if we give it to 2.3%, it becomes 2.6%. so it changes from 0.3% loss to 0.4% 
gain;

Everything else should be same.

-- 
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/88a7bab9-6375-4edd-ae87-0ddb6f2340a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Re: Round 1B 2018 Rounding Error : proof that we must maximize the number of rounded up languages

2018-05-15 Thread Xiongqi ZHANG
It's just greedy.

First of all, if percentage of one language is already rounded up, there is no 
point to assign any person to it any more.

This is easy to prove. Suppose you have a `best` solution that has ever assign 
any new persons to it, then it is easy to construct a new solution that assign 
all these new persons to a new language. The new solution should be no worse 
than the previous one, so it should also be a `best` solution.

Then you can assign the person one by one, giving priorities to the languages 
that has most round-down because they have better shots to become a round-up.

It is very obvious when 100/N is small, say 100/N = 0.01 and one language is at 
2.3% and the other one is at 5.4%
It is easy to tell that it require more votes to turn 2.3% to 2.5%

It become quite different when 100/N is significant large, say 100/N = 0.8
but still, we want to give it to 5.4%

1) if we give it to 5.4%, it becomes 6.2%, so it changes from 0.4% loss to 0.8% 
gain;

2) if we give it to 2.3%, it becomes 3.1%. so it changes from 0.3% loss to 0.9% 
gain;

you can see there is no difference, we always gain 1.2% no matter which one to 
assign.

in fact, case 2 may still be worse, if after you add the person to it, it still 
remains in round-down.
 

-- 
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/1778633a-a14b-4bbb-8bc8-d25e6ab144cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Re: Round 1B 2018 Rounding Error : proof that we must maximize the number of rounded up languages

2018-05-14 Thread Xiongqi ZHANG
the original sample is wrong because you shouldn’t compare two totally
different cases and count the number of the rounded up languages.

The correct statement is

Given an initial state, the answer must have the most rounded up languages,
among all reachable states.


So you shouldn’t just try to compare two states without mentioning the
initial state.
On Mon, May 14, 2018 at 8:55 AM Wing-chung Leung  wrote:

> The proof of the statement in the analysis is likely very complex. I tried
> for some time, but didn't get the proof done (or refuted).
>
> Anyway, the statement "We get the maximum answer when as many of these as
> possible are rounded up." is different from your post title ("we must
> maximize the number of rounded up languages").
>
> Your statement turns out to be false anyway. Consider the percentages
> (49.5, 49.5, 1) and (49.6, 49.6, 0.8) has the same total rounded
> percentage. And (49.5, 49.5, 1) is obviously NOT maximizing the number of
> rounded up languages.
>
> And this case is possible in the problem when n=1000, known number of
> votes for each language = (495, 495, 8). You have only 2 votes to assign,
> and that has clearly no effect with the total. But putting that (495, 495,
> 10) does not maximizing the number of rounded up languages.
>
>
> On Sunday, May 13, 2018 at 1:17:35 AM UTC, Ricola wrote:
> > Hello all,
> >
> > In the analysis for test set 3, it's written "We get the maximum answer
> when as many of these as possible are rounded up.".
> >
> > When I tried to solve it by myself I also thought about maximizing the
> number of rounded up languages but there was no way to prove myself that it
> would be the optimal solution. So I thought that I was taking a wrong
> direction. Then I saw in the analysis that it was but there is no
> mathematical proof.
> >
> > For example let's say that I have [49.5 49.5 1], if you round them up
> you get [50 50 1] and the total is 101.
> > Now let's say that I have [32.9 32.9 32.9 1.3], if you round them up
> you get [33 33 33 1] and the total is 100.
> >
> > However in the first case you rounded 2 languages and in the second case
> you rounded 3 languages. (Yes you will tell me that they would correspond
> to different distributions but since the theorem is true, it's normal that
> I cannot find a complete counter-example).
> >
> > If somebody has some mathematical (or pseudo-mathematical proof) that
> maximising the number of rounded languages maximises the sum that would be
> nice :-)
>
> --
> 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/0f8da8ce-7fac-46ab-b406-807623f20a07%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/CAGDEU-LsjxTX0EZaTQDZJqwcMW-57REQzOwtPMn5DJ%2B1%2Bg%3Di%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Ant stack problem - Can someone please tell me what is wrong with my solution?

2018-05-13 Thread Xiongqi ZHANG
There is no easy fix base on your approach.
You may need to rework your solution.

-- 
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/c1156580-9dfe-493c-89f2-b3588a46b318%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Ant stack problem - Can someone please tell me what is wrong with my solution?

2018-05-11 Thread Xiongqi ZHANG
You forget to clear the dict for each test case.

After fixing it, your solution still runs out of time.

-- 
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/70e12f7f-150d-46ea-928d-75b82aa2cdd6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Can someone please tell me why this is generating Runtime error on codejam (TroubleSort).

2018-05-09 Thread Xiongqi ZHANG
Sorry I didn't make it clear.

I am just talking about the quicksort provided by standard library. not any 
implementation of quicksort.

-- 
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/ccf3e841-9146-46d6-89f5-ce7ec50ceb79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Can someone please tell me why this is generating Runtime error on codejam (TroubleSort).

2018-05-09 Thread Xiongqi ZHANG
I don't believe the test data is actually generated to make the quicksort O(N^2)

You can't hack a submission either.

-- 
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/1da80e37-da67-4701-addb-f870f8eb9128%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Has anyone solved Question 3 from round 1C in python?

2018-05-08 Thread Xiongqi ZHANG
The original solution is also O(NK), keep in mind that the size of D never 
exceed 139. So it does not matter whether you want to check the boundary from 
above or below. It is always O(139) for worst case.

Use binary search for finding the boundary could be faster, but the runtime 
could be dominated by the following loop anyway.

-- 
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/8a52fe2a-345a-43f8-89b6-e934fd38ad4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Rules confusion: which attemt will be counted towards final score?

2018-05-07 Thread Xiongqi ZHANG
During the round, whenever you make an attempt, you will see how many
Visible test sets it passed, but you will not see results for any Hidden
test sets. For your last attempt (only!), you will see that the Hidden test
sets have either been skipped (because you did not pass a Visible test
set), or have results that will not be revealed during the round.

see https://codejam.withgoogle.com/codejam/resources/faq#visible-hidden
On Mon, May 7, 2018 at 4:46 PM Carlos Segura <carlossegu...@gmail.com>
wrote:

> Where did you find the next rule: "hidden test won't be run if visible
> test is not passed"?
>
> 2018-05-07 18:11 GMT-05:00 Xiongqi ZHANG <zhangxion...@gmail.com>:
>
>> If your last submission solve the hidden but not the visible test (this
>> is extremely unlikely though), you don't get any point for this attempt
>> because the hidden test won't be run if visible test is not passed.
>>
>> --
>> 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/ef9fc367-f0e5-4c00-ae21-10c7f4825694%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/CA%2BHD4Fyc6EgW_cx6Zn0%3DczuEToJs6tjbyZbBrfw0dnjQ6LV1Tw%40mail.gmail.com
> <https://groups.google.com/d/msgid/google-code/CA%2BHD4Fyc6EgW_cx6Zn0%3DczuEToJs6tjbyZbBrfw0dnjQ6LV1Tw%40mail.gmail.com?utm_medium=email_source=footer>
> .
> 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/CAGDEU-%2B6A569-6J%3DvaWstsRsFx-A3nwxM3HuGcjhwmvE7jL9GQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Rules confusion: which attemt will be counted towards final score?

2018-05-07 Thread Xiongqi ZHANG
If your last submission solve the hidden but not the visible test (this is 
extremely unlikely though), you don't get any point for this attempt because 
the hidden test won't be run if visible test is not passed.

-- 
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/ef9fc367-f0e5-4c00-ae21-10c7f4825694%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Re: Has anyone solved Question 3 from round 1C in python?

2018-05-07 Thread Xiongqi ZHANG
Thanks for the explanation. That's very helpful.

-- 
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/74e61fe8-8e16-4199-8a88-4e1f4128049a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Re: Could someone tell me why my c++ code got runtime error failure when I submit?

2018-05-07 Thread Xiongqi ZHANG
Because it has a bug that will cause null pointer exception.

-- 
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/c744848e-e6bd-4295-ae67-e0da708faf88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Re: Has anyone solved Question 3 from round 1C in python?

2018-05-07 Thread Xiongqi ZHANG
Ah ha, you used floating points in converting my variant. What's the reason 
behind that?

-- 
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/65d58ea8-8a3f-423e-b400-557dbb3f3e7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Could someone tell me why my c++ code got runtime error failure when I submit?

2018-05-06 Thread Xiongqi ZHANG
And I fixed the bug for you.

check out https://ideone.com/OeN0s7 and find the difference.

-- 
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/d2b9850a-9b6d-4375-bb67-d9bf551889ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Could someone tell me why my c++ code got runtime error failure when I submit?

2018-05-06 Thread Xiongqi ZHANG
in searchNextLevel()
there is a line

curr = curr->subTrie[idx];
This can result in curr being null.
and later there is another line

if (curr->subTrie[idx2] == NULL)

which might throw is curr is null

In general, your code is not doing what you want it to do (BFS base on your 
comment)

-- 
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/876e9a9f-8b7f-4f80-a18f-e69cf74b13b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Has anyone solved Question 3 from round 1C in python?

2018-05-05 Thread Xiongqi ZHANG
That's pretty odd.

I did some optimization (not affecting worst case complexity though) and passed.
But I serious doubt that the time limit for python(3?) is sufficient.

see my code at https://ideone.com/Qzgziu

-- 
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/b58c3f5e-9961-4a7d-b995-3a10ba186347%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Could someone help me to understand why my implementation for Bit Party gives wrong answer? (Java)

2018-05-02 Thread Xiongqi ZHANG
You are absolutely right and I totally agree with you.

I think what you want is a "Learn mode", which we can use to improve skills.
While the "Practice mode" is more or less like a "Virtual Contest" that 
simulate the environment for a real contest, and we can use to make ourselves 
prepared.
Analysis should be part of the "Learn mode" though.

-- 
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/105bd91a-37a8-4e04-a30c-8f971932e1aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Could someone help me to understand why my implementation for Bit Party gives wrong answer? (Java)

2018-05-02 Thread Xiongqi ZHANG
Didn't get your point. I don't understand why it is the same logic.

My logic is since releasing the test case could do both good thing or bad 
things, so there is a reason not to release it, despite the fact that it can do 
good thing. (It is a tradeoff isn't it)
I didn't say that it MUST NOT be released.

The same logic could apply to GCC if people believe that it bring more harm 
than benefits. (But that is not the case)

-- 
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/fc820a8a-775e-41c1-aeda-1d68d102c900%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Could someone help me to understand why my implementation for Bit Party gives wrong answer? (Java)

2018-05-02 Thread Xiongqi ZHANG
> I can't imagine why anybody would ever consider just fixing the symptom 
> rather than the root cause.

Because they don't realize that it is just the symptom rather than the root 
cause? Not everyone is smart as you that can easily identify the root cause.

-- 
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/6d7d4c75-fa29-4dcb-ba08-6c09a4ce18d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Could someone help me to understand why my implementation for Bit Party gives wrong answer? (Java)

2018-05-02 Thread Xiongqi ZHANG
> There is absolutely no valid justification for that, considering that this is 
> for *practice* (they even explain how to solve the problems!)

Telling you how to solve a problem is different from verifying that you have a 
correct implementation. The judging system is supposed to be working like a 
black box test.
If your solution failed to pass the black box test, then you should figure out 
the inconsistency between your implementation and the official solution.
Keep in mind that you can always come up with your own test data. You just need 
a random test case generator and a naive but correct solution.

If you have access to the data set that your implementation will fail, you are 
likely just fixing the symptom, not the root cause, and continue to fail on 
some next data set. (unless it is just a small mistake, which you can probably 
figure it out on your own using some simple data set)

Also, there are plenty of online judging systems that don't reveal their data 
set (in practice mode too), so I believe there is indeed some valid 
justification.

Meanwhile, I agree that more complicated and non-trivial test case can be 
provided as the sample input/output in practice mode (not the full one used in 
a black box test though). 

-- 
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/83e88344-54b6-4658-af9b-eed59b5ccc75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Can someone help me, why my solution failed at 2018 1B: Rounding Error problem?

2018-05-01 Thread Xiongqi ZHANG
Looks like you are using python3

There is another thread mentioning that the built-in round() in python3 does 
not work as expected.

It rounds the number to the nearest even.

so round(0.5) = 0 and round(1.5) = 2

-- 
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/8402a730-b7ba-45c3-ae2f-3ed48cfe42ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Round 1B. Rounding Error. Issue with C++ solution.

2018-05-01 Thread Xiongqi ZHANG
To solve the problem CORRECTLY, you need infinite precision in doing floating 
arithmetic.

Or you should just use integers to avoid all the precision issue.

-- 
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/450abbe9-9c31-4256-81fa-df462ad9698a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Why does this round 1B Transmutation solution fail?

2018-05-01 Thread Xiongqi ZHANG
r1, r2 = formulas[metal]

if r1 in encountered or r2 in encountered:
return False

Adding the above two lines with get your solution pass the first two data
sets.
Basically if either r1 or r2 is one of the metal you encountered before,
you don't really want to use any of them to make a new metal.

Your solution will still run out of time for the hardest data set.

Yngve Ådlandsvik 于2018年5月1日周二 下午1:36写道:

> Here's my Transmutation code:
>
> https://gist.github.com/ymgve/5390788df398e95796d26002466d592d
>
> Why does this fail? I've looked at other people's solutions and it's
> basically the same as mine.
>
> --
> 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/d44412bd-6d0c-4d5f-8ac2-78330f44e380%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/CAGDEU-Jyyv6eQF0rMtmCSkYLPk2T_UYSTHKza0WLjqwh3tAG-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Why didn't my solution for Rounding Error in Round 1B 2018 pass the hidden test set?

2018-05-01 Thread Xiongqi ZHANG
while num * 100 / N - int(num * 100 / N) < 0.5:
num += 1

This is too slow for large input. Instead you can calculate the least
number to get a round up.


   1. for T in range(int(input())):
   2. N, L = list(map(int, input().split()))
   3. C = list(map(int, input().split()))
   4.
   5. if 100 % N != 0:
   6. remaining = N - sum(C)
   7. counts = C + [0 for i in range(remaining)]
   8.
   9. least = 0
   10. while least * 100 / N - int(least * 100 / N) < 0.5:
   11. least += 1
   12. needed = []
   13. for cnt in counts:
   14. if cnt <= least:
   15. needed.append(least - cnt)
   16. else:
   17. num = cnt
   18. while num * 100 / N - int(num * 100 / N) < 0.5:
   19. num += 1
   20. needed.append(num - cnt)
   21.
   22. needed, counts = list(map(list, zip(*sorted(zip(needed, counts)
   23.
   24. for i in range(len(counts)):
   25. if needed[i] <= remaining:
   26. counts[i] += needed[i]
   27. remaining -= needed[i]
   28. counts[-1] += remaining
   29.
   30. result = []
   31. for cnt in counts:
   32. percentage = cnt * 100 / N
   33. if percentage - int(percentage) < 0.5:
   34. result.append(int(percentage))
   35. else:
   36. result.append(int(percentage) + 1)
   37.
   38. print('Case #' + str(T + 1) + ': ' + str(sum(result)))
   39.
   40. else:
   41. print('Case #' + str(T + 1) + ': 100')


Arti Schmidt 于2018年5月1日周二 下午1:41写道:

> My solution passed both visible test sets, but I got a
> "TIME_LIMIT_EXCEEDED" error on the hidden one. As far as I can tell, I did
> exactly what was described to solve test set 3 in the analysis. What did I
> do wrong?
>
> (Python 3)
>
> for T in range(int(input())):
> N, L = list(map(int, input().split()))
> C = list(map(int, input().split()))
>
> if 100 % N != 0:
> remaining = N - sum(C)
> counts = C + [0 for i in range(remaining)]
>
> needed = []
> for cnt in counts:
> num = cnt
> while num * 100 / N - int(num * 100 / N) < 0.5:
> num += 1
> needed.append(num - cnt)
>
> needed, counts = list(map(list, zip(*sorted(zip(needed, counts)
>
> for i in range(len(counts)):
> if needed[i] <= remaining:
> counts[i] += needed[i]
> remaining -= needed[i]
> counts[-1] += remaining
>
> result = []
> for cnt in counts:
> percentage = cnt * 100 / N
> if percentage - int(percentage) < 0.5:
> result.append(int(percentage))
> else:
> result.append(int(percentage) + 1)
>
> print('Case #' + str(T + 1) + ': ' + str(sum(result)))
>
> else:
> print('Case #' + str(T + 1) + ': 100')
>
> --
> 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/c7efd9ae-a678-476d-b579-e64bf35c6514%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/CAGDEU-%2BX6-%3DbtSAyjD%3Dc2KnE3NU2xa_U8CmmLqhrhmtqLRGLkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Why does my code fail Test Set 1 of 1B Rounding Error?

2018-05-01 Thread Xiongqi ZHANG
https://github.com/fonttools/fonttools/issues/664
found a page about the diff between the round() in py2 and py3.

I think this might be the cause.
On Tue, May 1, 2018 at 11:56 AM Bartholomew Furrow <fur...@gmail.com> wrote:

> I would be astonished to discover that the different languages had
> different test cases. IMO it's more likely that Python2 has a different
> native round method, or that the math leading up to the call to round() was
> executed in a way that caused a different result.
>
> On Tue, May 1, 2018 at 12:47 PM Xiongqi ZHANG <zhangxion...@gmail.com>
> wrote:
>
>> I think the test case are different for python2/3 for some reason. If we
>> run the code in python2 against the test case set up for python3, it might
>> failed as well.
>>
>> Bartholomew Furrow <fur...@gmail.com>于2018年5月1日周二 上午11:20写道:
>>
>>> I'm surprised it worked in Python2! Generally if rounding exactly is an
>>> important part of the problem, you should do everything in integers.
>>> Actually, for most problems, you should do everything you can in integers
>>> if it's possible.
>>>
>>> On Tue, May 1, 2018 at 11:41 AM Xiongqi ZHANG <zhangxion...@gmail.com>
>>> wrote:
>>>
>>>> I submitted almost the same code for python2, and it was accepted.
>>>> But it keeps failing for python3.
>>>>
>>>> Looks like the floating point arithmetic is the problem.
>>>> I rewrite the logic for round() and it get accepted.
>>>>
>>>>
>>>>1. import bisect
>>>>2.
>>>>3. def isRoundUp(a, b):
>>>>4. a = 100 * a % b
>>>>5. if a * 2 >= b:
>>>>6. return True
>>>>7. return False
>>>>8.
>>>>9. def myRound(a, b):
>>>>10. base = 100 * a // b;
>>>>11. if isRoundUp(a, b):
>>>>12. base = base + 1
>>>>13. return base
>>>>
>>>>
>>>>1.
>>>>2. def solve():
>>>>3. N, L = map(int, input().split())
>>>>4. C = list(map(int, input().split())) # of length L
>>>>5. remaining = N - sum(C)
>>>>6. if 100 % N == 0:
>>>>7. return 100
>>>>8. # print("Beginning langs chosen:", C)
>>>>9.
>>>>10. # 1) Generate the targets which round up
>>>>
>>>>
>>>>1. targets = [i for i in range(1, N) if isRoundUp(i, N)]
>>>>
>>>>
>>>>1. targets += [N]
>>>>2. least = targets[0] if len(targets) > 0 else N
>>>>3. # print("Targets:", targets)
>>>>4.
>>>>5. # 2) Find distance for each language from nearest target
>>>>6. diffs = [None for _ in range(L)] # diffs from each language to
>>>>next target
>>>>7. for i in range(L):
>>>>8. ind = bisect.bisect_left(targets, C[i])
>>>>9. diffs[i] = (targets[ind] - C[i], i)
>>>>10. # alternatively, use a heap (diffs, lang_ind)
>>>>11. diffs.sort()
>>>>12. # print("Diffs:", diffs)
>>>>13.
>>>>14. # 3) Allocate the persons, generating as many round ups as
>>>>possible
>>>>15. for i in range(L):
>>>>16. margin, ind = diffs[i]
>>>>17. if margin >= least or remaining < margin: # we can just form
>>>>new language groups now
>>>>18. break
>>>>19. C[ind] += margin
>>>>20. remaining -= margin
>>>>21.
>>>>22. # 4) Calculate
>>>>
>>>>
>>>>1. total = sum(myRound(C[i], N) for i in range(L))
>>>>
>>>>
>>>>1. # deal with the remaining
>>>>
>>>>
>>>>1. total += (remaining // least) * myRound(least, N)
>>>>
>>>>
>>>>1. remaining = remaining % least
>>>>
>>>>
>>>>1. total += myRound(remaining, N)
>>>>
>>>>
>>>>1. # print("Final langs chosen:", C)
>>>>2. return total
>>>>3.
>>>>4.
>>>>5. T = int(input())
>>>>6. for t in range(T):
>>>>7. ans = solve()
>>>>8. print("Case #{}: {}".format(t+1, ans))
>>>>
>>>>
>>>>
>>>>
>>>> Jeffrey Yu

Re: [gcj] Why does my code fail Test Set 1 of 1B Rounding Error?

2018-05-01 Thread Xiongqi ZHANG
I think the test case are different for python2/3 for some reason. If we
run the code in python2 against the test case set up for python3, it might
failed as well.

Bartholomew Furrow <fur...@gmail.com>于2018年5月1日周二 上午11:20写道:

> I'm surprised it worked in Python2! Generally if rounding exactly is an
> important part of the problem, you should do everything in integers.
> Actually, for most problems, you should do everything you can in integers
> if it's possible.
>
> On Tue, May 1, 2018 at 11:41 AM Xiongqi ZHANG <zhangxion...@gmail.com>
> wrote:
>
>> I submitted almost the same code for python2, and it was accepted.
>> But it keeps failing for python3.
>>
>> Looks like the floating point arithmetic is the problem.
>> I rewrite the logic for round() and it get accepted.
>>
>>
>>1. import bisect
>>2.
>>3. def isRoundUp(a, b):
>>4. a = 100 * a % b
>>5. if a * 2 >= b:
>>6. return True
>>7. return False
>>8.
>>9. def myRound(a, b):
>>10. base = 100 * a // b;
>>11. if isRoundUp(a, b):
>>12. base = base + 1
>>13. return base
>>
>>
>>1.
>>2. def solve():
>>3. N, L = map(int, input().split())
>>4. C = list(map(int, input().split())) # of length L
>>5. remaining = N - sum(C)
>>6. if 100 % N == 0:
>>7. return 100
>>8. # print("Beginning langs chosen:", C)
>>9.
>>10. # 1) Generate the targets which round up
>>
>>
>>1. targets = [i for i in range(1, N) if isRoundUp(i, N)]
>>
>>
>>1. targets += [N]
>>2. least = targets[0] if len(targets) > 0 else N
>>3. # print("Targets:", targets)
>>4.
>>5. # 2) Find distance for each language from nearest target
>>6. diffs = [None for _ in range(L)] # diffs from each language to
>>next target
>>7. for i in range(L):
>>8. ind = bisect.bisect_left(targets, C[i])
>>9. diffs[i] = (targets[ind] - C[i], i)
>>10. # alternatively, use a heap (diffs, lang_ind)
>>11. diffs.sort()
>>12. # print("Diffs:", diffs)
>>13.
>>14. # 3) Allocate the persons, generating as many round ups as
>>possible
>>15. for i in range(L):
>>16. margin, ind = diffs[i]
>>17. if margin >= least or remaining < margin: # we can just form new
>>language groups now
>>18. break
>>19. C[ind] += margin
>>20. remaining -= margin
>>21.
>>22. # 4) Calculate
>>
>>
>>1. total = sum(myRound(C[i], N) for i in range(L))
>>
>>
>>1. # deal with the remaining
>>
>>
>>1. total += (remaining // least) * myRound(least, N)
>>
>>
>>1. remaining = remaining % least
>>
>>
>>1. total += myRound(remaining, N)
>>
>>
>>1. # print("Final langs chosen:", C)
>>2. return total
>>3.
>>4.
>>5. T = int(input())
>>6. for t in range(T):
>>7. ans = solve()
>>8. print("Case #{}: {}".format(t+1, ans))
>>
>>
>>
>>
>> Jeffrey Yun <thisisha...@gmail.com>于2018年5月1日周二 上午9:37写道:
>>
>>> # This is the Python code which followed the rationale of the Test Set 3
>>> analysis (N log N). Spent entirety of contest unsuccessfully debugging by
>>> looking for test cases which it fails, but getting Wrong Answer each time.
>>>
>>> import bisect
>>>
>>> def solve():
>>> N, L = map(int, input().split())
>>> C = list(map(int, input().split()))   # of length L
>>> remaining = N - sum(C)
>>> if 100 % N == 0:
>>> return 100
>>> # print("Beginning langs chosen:", C)
>>>
>>> # 1) Generate the targets which round up
>>> targets = [i for i in range(1, N) if round(100*i/N) >= 100*i/N]
>>> targets += [N]
>>> least = targets[0] if len(targets) > 0 else N
>>> # print("Targets:", targets)
>>>
>>> # 2) Find distance for each language from nearest target
>>> diffs = [None for _ in range(L)] # diffs from each language to next
>>> target
>>> for i in range(L):
>>> ind = bisect.bisect_left(targets, C[i])
>>> diffs[i] = (targets[ind] - C[i], i)
>>> # alternatively, use a heap (diffs, lang_ind)
>>> diffs.sort()
>>> # print("Diffs:

Re: [gcj] Why does my code fail Test Set 1 of 1B Rounding Error?

2018-05-01 Thread Xiongqi ZHANG
I submitted almost the same code for python2, and it was accepted.
But it keeps failing for python3.

Looks like the floating point arithmetic is the problem.
I rewrite the logic for round() and it get accepted.


   1. import bisect
   2.
   3. def isRoundUp(a, b):
   4. a = 100 * a % b
   5. if a * 2 >= b:
   6. return True
   7. return False
   8.
   9. def myRound(a, b):
   10. base = 100 * a // b;
   11. if isRoundUp(a, b):
   12. base = base + 1
   13. return base
   14.
   15. def solve():
   16. N, L = map(int, input().split())
   17. C = list(map(int, input().split())) # of length L
   18. remaining = N - sum(C)
   19. if 100 % N == 0:
   20. return 100
   21. # print("Beginning langs chosen:", C)
   22.
   23. # 1) Generate the targets which round up
   24. targets = [i for i in range(1, N) if isRoundUp(i, N)]
   25. targets += [N]
   26. least = targets[0] if len(targets) > 0 else N
   27. # print("Targets:", targets)
   28.
   29. # 2) Find distance for each language from nearest target
   30. diffs = [None for _ in range(L)] # diffs from each language to next
   target
   31. for i in range(L):
   32. ind = bisect.bisect_left(targets, C[i])
   33. diffs[i] = (targets[ind] - C[i], i)
   34. # alternatively, use a heap (diffs, lang_ind)
   35. diffs.sort()
   36. # print("Diffs:", diffs)
   37.
   38. # 3) Allocate the persons, generating as many round ups as possible
   39. for i in range(L):
   40. margin, ind = diffs[i]
   41. if margin >= least or remaining < margin: # we can just form new
   language groups now
   42. break
   43. C[ind] += margin
   44. remaining -= margin
   45.
   46. # 4) Calculate
   47. total = sum(myRound(C[i], N) for i in range(L))
   48. # deal with the remaining
   49. total += (remaining // least) * myRound(least, N)
   50. remaining = remaining % least
   51. total += myRound(remaining, N)
   52. # print("Final langs chosen:", C)
   53. return total
   54.
   55.
   56. T = int(input())
   57. for t in range(T):
   58. ans = solve()
   59. print("Case #{}: {}".format(t+1, ans))


Jeffrey Yun 于2018年5月1日周二 上午9:37写道:

> # This is the Python code which followed the rationale of the Test Set 3
> analysis (N log N). Spent entirety of contest unsuccessfully debugging by
> looking for test cases which it fails, but getting Wrong Answer each time.
>
> import bisect
>
> def solve():
> N, L = map(int, input().split())
> C = list(map(int, input().split()))   # of length L
> remaining = N - sum(C)
> if 100 % N == 0:
> return 100
> # print("Beginning langs chosen:", C)
>
> # 1) Generate the targets which round up
> targets = [i for i in range(1, N) if round(100*i/N) >= 100*i/N]
> targets += [N]
> least = targets[0] if len(targets) > 0 else N
> # print("Targets:", targets)
>
> # 2) Find distance for each language from nearest target
> diffs = [None for _ in range(L)] # diffs from each language to next
> target
> for i in range(L):
> ind = bisect.bisect_left(targets, C[i])
> diffs[i] = (targets[ind] - C[i], i)
> # alternatively, use a heap (diffs, lang_ind)
> diffs.sort()
> # print("Diffs:", diffs)
>
> # 3) Allocate the persons, generating as many round ups as possible
> for i in range(L):
> margin, ind = diffs[i]
> if margin >= least or remaining < margin:  # we can just form
> new language groups now
> break
> C[ind] += margin
> remaining -= margin
>
> # 4) Calculate
> total = sum(round(100*C[i]/N) for i in range(L))
> # deal with the remaining
> total += (remaining//least)*round(100*least/N)
> remaining = remaining % least
> total += round(100*remaining/N)
> # print("Final langs chosen:", C)
> return total
>
>
> T = int(input())
> for t in range(T):
> ans = solve()
> print("Case #{}: {}".format(t+1, ans))
>
> --
> 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/25768800-d3a3-48cf-b7dd-4aa93c39b61c%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/CAGDEU-JFfHWoto05TovKrt%2BZaSd5dpkPuVam9tLaOKbTPKWgbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Scoring for partially failed problems

2018-05-01 Thread Xiongqi ZHANG
In your case, hidden test will only be run on Attempt 6. And since your
Attempt 6 failed the visible test, hidden test will be skipped too.
On Tue, May 1, 2018 at 9:38 AM Arnav Sastry  wrote:

> Hi all,
>
> I'm trying to figure out why all of my judgments were skipped for
> Mysterious Road Signs (2nd problem) in Google Code Jam 2018 Round 1B.
>
> Based on the FAQ, the system should score either your last submission, or
> your earliest submission that passed the most visible test cases:
> https://codejam.withgoogle.com/codejam/resources/faq#how-score-determined
>
> In my case, I had the following attempts:
> Attempt 1: Fail, ?
> Attempt 2: Pass, ?
> Attempt 3: Fail, ?
> Attempt 4: Pass, ?
> Attempt 5: Pass, ?
> Attempt 6: Fail, ?
>
> I'd expect Attempt 2 to be judged on the large test set and used for my
> score. However, all 6 attempts show "The judgment was skipped." Can someone
> explain to me why this is?
>
> Best,
> Arnav Sastry
>
> --
> 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/bbda4c9b-044f-485a-95c2-8a083fd9651c%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/CAGDEU-%2B%2BNUfLFzLbr7SGpAc3syxncaKYW2C0rKCJV5QxH9HGrQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Please make input/output test case data available

2018-04-27 Thread Xiongqi ZHANG
I don't agree with the idea that "Following this logic, maybe you should stop 
publishing problem analyses as well?"

Problem analysis are provided to help you learn and improve, and probably you 
won't look at it unless you solved the problem yourself or finally gave up and 
admit that you cannot solve it anyway.

But test data is only useful for finding bug in your code and fix your broken 
solution. Mostly importantly, probably you can't help looking at it before you 
solved the solution (because you want to use it for debugging). 

-- 
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/a2cd3d60-e269-4f01-b26b-927b5a1c5b3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Runtime Error in C++. Solved.

2018-04-21 Thread Xiongqi ZHANG
I know that this section is for Distributed Code Jam only.
But previously we were submitting output to GCJ and code to DCJ, so this won't 
be a problem for GCJ, but just DCJ.
This year, we change the format of GCJ, so same rule should be applied to GCJ 
as well.
I guessed they didn't update the term to reflect this change.

-- 
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/1c788a9e-d8ab-41a5-a176-d1001e6d2d44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Runtime Error in C++. Solved.

2018-04-21 Thread Xiongqi ZHANG
Check https://codejam.withgoogle.com/codejam/terms

4.3 Submitting Solutions for Distributed Code Jam Problems.
  (A) Submission Requirements.
(13) must make all instances exit with a 0 exit code.

-- 
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/b96e72fc-ca9e-445f-8a7b-5924a2250194%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Runtime Error in C++. Solved.

2018-04-21 Thread Xiongqi ZHANG
Not meant to be harsh, isn't this a common knowledge that exit code is used to 
determine whether a child process finished w/ or w/o any error?

https://stackoverflow.com/questions/9426045/difference-between-exit0-and-exit1-in-python

-- 
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/082fa56b-8409-4787-ac0e-2edb04729ec6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Submission and Penalty System

2018-04-18 Thread Xiongqi ZHANG
Let me answer that for you.

After you resubmit, you only get penalty time if your second submission
passed test2.
Therefore, you won't get penalty time if it is wrong on test2 or test1.
Also you won't lose point if it failed on test1.

Summary:

1. Hidden Tests only counted for your last submission; (even if previous
submissions get it right, you won't get those points.)
2. Visible Tests will be counted for all your submission;
3. Among all the submissions, the first one that give you most scores will
be used to calculate your final score and penalty time. e.g. if your 7th
attempt give you the highest score, then you earn that score with penalty
time equals to 4 minutes * 6 = 24 minutes.

Artem Voronin 于2018年4月18日周三 下午7:37写道:

> On Monday, April 16, 2018 at 11:37:49 PM UTC+4, Pablo Heiber wrote:
> > Hi,
> >
> >
> > We've been asked this or similar questions many times. The short answer
> is that the trade-off between complexity of the system (not our code, but
> the specifications of the system) and the benefits are small enough not to
> do it. If you believe that submitting a small-only solution first gives you
> a strategic advantage, you are welcome to do so, at the relatively cheap
> prize of 4 minutes of penalty. It makes sense to us that someone who can
> write a full solution directly instead of going through the intermediate
> step of a small-only solution receives a small advantage.
> >
> >
> > The judging and scoring mechanism is already sufficiently complicated
> that we get a good number of questions about it. It would only make sense
> to make it more complicated if the benefits were great. Saving 4 minutes of
> penalty in some cases to some subset of people doesn't seem like such a
> large benefit.
> >
> >
> > I would like to reiterate that this is not about the complexity of our
> code executing the specification, but complexity of the specification
> itself. Being able to explain things clearly and briefly is super
> important, and even though for some people this may look like a small
> change, for others is one more barrier to understand the contest as a whole.
> >
> >
> > Best,
> > Pablo
> >
> >
> > On Fri, Apr 13, 2018 at 11:57 AM taranpreetsinghchhabra <
> taranpreets...@gmail.com> wrote:
> > Hello
> >
> >
> >
> > This is a request thread.
> >
> >
> >
> > I would like to request admins to allow us separate options for
> submitting for small and large differently, just like in old system,
> because if we develop a solution for small first and submit and later on
> make solution for large, we have to incur a penalty.
> >
> >
> >
> > The benefit of different submit would be for both users as well as the
> judge. Many times people know that their solution is intended for small
> only, So, if we have different submit options, judge can be relieved for
> running the same solution for large data sets.
> >
> >
> >
> > Also, if a user intend to submit large later on, He too will be saved
> from minute penalty, as well as judge will not have to judge small data set
> again, which helps to reduce overload.
> >
> >
> >
> > Concluding, The system i recommend (request), is the one same as old
> platform, with the change of uploading source code instead of working with
> test files, with same penalty system as earlier.
> >
> >
> >
> > I know this might involve the amount of work i can't even imagine, but
> surely This system is worth a thought. So i shared my opinion. Rest, as
> always, will be your choice.
> >
> >
> >
> > Regards
> >
> >
> >
> > --
> >
> > 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/43cc6498-603a-4b67-b9e5-9eae5825ef71%40googlegroups.com
> .
> >
> > For more options, visit https://groups.google.com/d/optout.
>
> Hey Pablo,
>
> you mentioned "complexity of the specification itself", I assume you mean
> difficulty to use/understand it for user, it seems current specification is
> extremely complex already and suggestion above will make it simpler.
>
> I can give you an example: you submit a solution, it passes test1, will be
> judged on test2, you find a bug (test2 will be judged wrong), you resubmit,
> now questions: will you get penalty time if it will be again wrong on test2
> ?  will you get penalty time if it will be wrong on test1 ? will you get
> scores for test1 if it will be wrong on test1 ?
>
>
>
> --
> 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.
> 

Re: [gcj] 2018 1A Edgy Baking problem analysis

2018-04-18 Thread Xiongqi ZHANG
To make it simple, you can also think it this way.

The minimum added perimeter for cutting a piece is the weight. (must be 
integers)
The maximum added perimeter for cutting a piece is the value. (can be floats)

min(sum of all weight, P - existing perimeter) is the maximum weight you can 
carry.

Find out the maximum value you can carry with standard knapsack, say V
The answer is simply min(P, V + existing perimeter)

-- 
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/0c6ca684-934d-4db0-97fa-ebb2c1b43c14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] What is the point of giving penalties for C++ compile errors?

2018-04-17 Thread Xiongqi ZHANG
did you meant

> 2. Your solution for **invisible** set has to also work for the **visible** 
> set?

-- 
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/9757b80d-8a9b-447b-a523-3db0adcb7d9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Round 1A is over! Two more Round 1s to go!

2018-04-16 Thread Xiongqi ZHANG
In fact, I think Compilation Error should not be treated as incorrect 
submission.
Many of us use different IDE that has different environment set up, which 
easily cause compilation errors like missing header.

Personally I used Visual Studio and nearly every time I forgot to add header 
like  in order to use memset().

-- 
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/777c2a32-0f70-4845-8339-336361d57a0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] The Qual Round is over!

2018-04-08 Thread Xiongqi ZHANG
Previously you also had to estimate the runtime for your large submission.
If you started downloading the input file for large submission, and
couldn’t finish before running out of time, you still lose points.
The new system however, allows you to submit again if you later find a
better solution that no longer time out on large data set.
On Sun, Apr 8, 2018 at 1:08 PM Leandro Coutinho <lescoutinh...@gmail.com>
wrote:

> Hmm good point.
>
> So CodeJam is worst now.
>
> Worst is not the best word. The previous system was really good.
>
> Em Dom, 8 de abr de 2018 17:04, Xiongqi ZHANG <zhangxion...@gmail.com>
> escreveu:
>
>> The hidden test is run after the contents ends. How is it possible to
>> tell you that your program will finish or not if it was not actually run?
>> On Sun, Apr 8, 2018 at 12:56 PM Leandro Coutinho <lescoutinh...@gmail.com>
>> wrote:
>>
>>> Good point.
>>>
>>> They should let us know if the program finished on time. They can do
>>> this without saying that it is correct or not.
>>>
>>> The other problem is about correctness. Hidden/large should be about
>>> performance ...
>>>
>>> Em Dom, 8 de abr de 2018 16:43, Felix Voituret <felix.voitu...@gmail.com>
>>> escreveu:
>>>
>>>> Well the real difference here is that you do not know if the time limit
>>>> was respected for the hidden dataset (previously large). So you really has
>>>> to ensure required points from visible one that you can control unless you
>>>> estimate correctly time complexity regarding dataset limits.
>>>>
>>>> Envoyé de mon iPhone
>>>>
>>>> > Le 8 avr. 2018 à 20:29, newbie007 <lescoutinh...@gmail.com> a écrit :
>>>> >
>>>> > Usually in the qualification round the first two problems are simple
>>>> and with no tricks.
>>>> >
>>>> > I got A and B correct for the small data sets, so I assumed it was
>>>> fine.
>>>> >
>>>> > But then wrong for A large and time exceed for B large. Oo
>>>> >
>>>> > Probably I was too careless, but I think CodeJam missed the
>>>> qualification round purpose this year.
>>>> >
>>>> > --
>>>> > 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/1c05cf0e-d772-4b96-879c-b61535bd9145%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/04C481DF-7DFB-4A75-9A85-C2DFF300CE09%40gmail.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/CAN6UTazuPkM5riqnVc-39%3D6E0Z0YO0J%3DHdaGugYWQUJN%3Day7XA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/google-code/CAN6UTazuPkM5riqnVc-39%3D6E0Z0YO0J%3DHdaGugYWQUJN%3Day7XA%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> 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-co

Re: [gcj] The Qual Round is over!

2018-04-08 Thread Xiongqi ZHANG
The hidden test is run after the contents ends. How is it possible to tell
you that your program will finish or not if it was not actually run?
On Sun, Apr 8, 2018 at 12:56 PM Leandro Coutinho 
wrote:

> Good point.
>
> They should let us know if the program finished on time. They can do this
> without saying that it is correct or not.
>
> The other problem is about correctness. Hidden/large should be about
> performance ...
>
> Em Dom, 8 de abr de 2018 16:43, Felix Voituret 
> escreveu:
>
>> Well the real difference here is that you do not know if the time limit
>> was respected for the hidden dataset (previously large). So you really has
>> to ensure required points from visible one that you can control unless you
>> estimate correctly time complexity regarding dataset limits.
>>
>> Envoyé de mon iPhone
>>
>> > Le 8 avr. 2018 à 20:29, newbie007  a écrit :
>> >
>> > Usually in the qualification round the first two problems are simple
>> and with no tricks.
>> >
>> > I got A and B correct for the small data sets, so I assumed it was fine.
>> >
>> > But then wrong for A large and time exceed for B large. Oo
>> >
>> > Probably I was too careless, but I think CodeJam missed the
>> qualification round purpose this year.
>> >
>> > --
>> > 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/1c05cf0e-d772-4b96-879c-b61535bd9145%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/04C481DF-7DFB-4A75-9A85-C2DFF300CE09%40gmail.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/CAN6UTazuPkM5riqnVc-39%3D6E0Z0YO0J%3DHdaGugYWQUJN%3Day7XA%40mail.gmail.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/CAGDEU-%2BAV38V8MWAYvrvOJTvuH%2BROa_gAzEouYK2EUOS_kD1QA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Are there any issues with python submission I should know about?

2018-04-01 Thread Xiongqi ZHANG
well then a = 0, b = 1. This does the same thing
On Sun, Apr 1, 2018 at 1:18 PM Felix Voituret <felix.voitu...@gmail.com>
wrote:

> Well the case a = 3 is not supposed to happen as problem limit specify a =
> 0 (unless it has changed since Friday).
>
> Envoyé de mon iPhone
>
> > Le 1 avr. 2018 à 21:51, Xiongqi ZHANG <zhangxion...@gmail.com> a écrit :
> >
> > Passing local test tool does not mean your solution will also pass the
> final test.
> >
> > Testing tool is simply used for checking input/output flow and format.
> The test case provided is almost certain to be trivial.
> >
> > In your case, you should stop reading from stdin when you saw
> 'WRONG_ANSWER' because the program that interact with yours will no longer
> providing any data.
> >
> > Besides, your binary search is incorrect.
> > Try case like
> > a = 3, b = 4, solution = 4
> > you can easily check that your solution will keep checking if 3 is
> correct answer, and being told that 3 is TOO_SMALL and never asking for 4
> (which is the correct answer)
> >
> > --
> > 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/d1d9acc5-aef5-4765-9634-270cc4290203%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/61F27436-E011-411D-97DD-08290A304839%40gmail.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/CAGDEU-LdarffvCXD9qry0-fiLeRk1bTrYK4Z6Lm_ctDBsGbFmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Are there any issues with python submission I should know about?

2018-04-01 Thread Xiongqi ZHANG
Passing local test tool does not mean your solution will also pass the final 
test.

Testing tool is simply used for checking input/output flow and format. The test 
case provided is almost certain to be trivial.

In your case, you should stop reading from stdin when you saw 'WRONG_ANSWER' 
because the program that interact with yours will no longer providing any data.

Besides, your binary search is incorrect.
Try case like
a = 3, b = 4, solution = 4
you can easily check that your solution will keep checking if 3 is correct 
answer, and being told that 3 is TOO_SMALL and never asking for 4 (which is the 
correct answer)

-- 
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/d1d9acc5-aef5-4765-9634-270cc4290203%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Are there any issues with python submission I should know about?

2018-04-01 Thread Xiongqi ZHANG
Would you share your python solution? Maybe we can take a look.

-- 
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/3b224b01-3ff8-4beb-8b33-a3d14d25d628%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Keep running in TIME_LIMIT_EXCEEDED on C

2018-03-30 Thread Xiongqi ZHANG
For each exchange, your program needs to use standard output to send a **single 
line** with one integer Q

I think the reason why you get TLE is that you need to print a newline for each 
Q you print.

Also, your make a typical mistake writing the binary search.

If the input is A = 3 and B = 4, and the correct answer is 4, your code will 
keep asking for Q = 3, and getting response that 3 is TOO_SMALL.


Here is the correct solution:

```C
#include 
#include 
#include 


int main() {
int T; //n cases
int A, B; //lower exlusive bound, upper inclusive bound
int N; //max number of guessing
int Q; //my try
char res[13];

int i, k;

scanf("%d", );

for (i = 1; i <= T; i++) { //stops after T cases
scanf("%d", );
scanf("%d", );
scanf("%d", );
for (k = 0; k < N; k++) { //stops after N tries
Q = (B + A + 1) / 2; //gets the avarage between min,max
fflush(stdout); //random fflush 1
printf("%d\n", Q);
fflush(stdout); //random fflush 2
scanf("%s", res); //get the answer from the machine
if (res[4] == 'S') //TOO_SMALL
A = Q;
else if (res[4] == 'B') //TOO_BIG
B = Q - 1;
else if (res[4] == 'E') //CORRECT
k = N;
else if (res[4] == 'G') //WRONG_ANSWER
return 0;
else
k = N; //just in case to make the run end
fflush(stdout); //random fflush 3


}
}

return 0;
}
```

-- 
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/52139ef2-fb44-453f-bc0e-12012988ac5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Kickstart Round A 2018: C. Scrambled Words

2018-03-22 Thread Xiongqi ZHANG
I believe what the analysis means is that

Given a sub-string in the larger string, finding the matching words in
dictionary takes almost O(1).
You don't need to go through all the words in dictionary, just the ones
with same length, same starting, same ending letters and same frequency
array in the middle.

Pedro Osório 于2018年3月22日周四 下午3:32写道:

> The analysis presented here mentions an approach that would take O(N
> sqrt(M)) for the large case:
> https://code.google.com/codejam/contest/9234486/dashboard#s=a=2
>
> However, the approach that is described (as far as I understand it) still
> compares the 26 frequency counts for every word in the dictionary at each
> position in the larger string:
>
> "for each such length, we perform the same process as above, checking
> against only the dictionary words with that length"
>
> This would still be O(N*L) - or O(N*L*K) if we decide to consider the size
> of the alphabet K=26 in the analysis.
>
> What am I missing?
>
> --
> 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/37d8693f-e33d-4611-8b1a-84a34de8cb03%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/CAGDEU-LzEvBFfL_bO50zUPHdZQqz%2Bxs8EULceriYaKXLDw7dZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Google Code Jam 2018 registration is open

2018-03-06 Thread Xiongqi ZHANG
Missed one point. The points for the hidden test can only be earned by the
last submission.
Previous submission do not get points for hidden test, even if they passed.

Xiongqi ZHANG <zhangxion...@gmail.com>于2018年3月6日周二 下午8:11写道:

> I found one interesting rule.
>
> For each problem, only two submissions matters:
> 1) the first submission that passed the most visible tests;
> 2) the last submission.
>
> Whichever grant you more points. In case they have the same points, the 1)
> one will be used.
>
> Bartholomew Furrow <fur...@gmail.com>于2018年3月6日周二 下午8:02写道:
>
>> OK, things seem to have changed a tiny bit
>> <https://codejam.withgoogle.com/codejam/resources/faq#changing-in-2018>.
>> I've read through the FAQ and here's my attempt at describing what's
>> different:
>>
>> - Code is now run server-side. You don't download i/o sets.
>> - Available languages: Bash, C, C++, C# (mono), Go, Haskell (ghc), Java
>> 8, Javascript (nodejs), Python2, Python3, PHP, and Ruby. That covers 97.5%
>> of what people used in last year's qualification round.
>> - New "interactive" problems that let the server respond to the user's
>> output, and vice-versa.
>> - Instead of small/large, there's now "visible" / "hidden" -- you get to
>> see your results on "visible" sets. There are some details
>> <https://codejam.withgoogle.com/codejam/resources/faq#visible-hidden>,
>> especially regarding resubmission.
>> - No "ask a question" in the platform -- only email. I presume this might
>> come for next year.
>> - There will be a chance to try the new platform prior to the
>> qualification round, in case 27 hours isn't long enough to figure it out.
>> - 4500 advance to round 2. 1000 advance to round 3. 1000 shirts.
>>
>> I'm really excited about the new problem type, and excited about not
>> having to deal with i/o files, and about the problemsetters not being
>> constrained by variable hardware anymore! Does anyone see anything I missed?
>>
>> Bartholomew
>>
>> On Tue, Mar 6, 2018 at 4:47 PM Joseph DeVincentis <dev...@gmail.com>
>> wrote:
>>
>>> Registration is open and the full schedule is up.
>>> https://code.google.com/codejam/
>>>
>>>
>>> --
>>> 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/CAMAzhzgTpkSGUefgy9bNVyDuLZHaB%3Dj6m1OwO7x35df4hyghgQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/google-code/CAMAzhzgTpkSGUefgy9bNVyDuLZHaB%3Dj6m1OwO7x35df4hyghgQ%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> 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/CAHaiWHOspb9VUrD6-VapUsNZv4%2Bx90m_L%3DLjpHyrM8WTcB-cqw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/google-code/CAHaiWHOspb9VUrD6-VapUsNZv4%2Bx90m_L%3DLjpHyrM8WTcB-cqw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> 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/CAGDEU-JBBQzo5%3DgeUzzm6ncNCix5-StjZ%2BDPOVt%3DDaixDm-R_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Google Code Jam 2018 registration is open

2018-03-06 Thread Xiongqi ZHANG
I found one interesting rule.

For each problem, only two submissions matters:
1) the first submission that passed the most visible tests;
2) the last submission.

Whichever grant you more points. In case they have the same points, the 1)
one will be used.

Bartholomew Furrow 于2018年3月6日周二 下午8:02写道:

> OK, things seem to have changed a tiny bit
> .
> I've read through the FAQ and here's my attempt at describing what's
> different:
>
> - Code is now run server-side. You don't download i/o sets.
> - Available languages: Bash, C, C++, C# (mono), Go, Haskell (ghc), Java 8,
> Javascript (nodejs), Python2, Python3, PHP, and Ruby. That covers 97.5% of
> what people used in last year's qualification round.
> - New "interactive" problems that let the server respond to the user's
> output, and vice-versa.
> - Instead of small/large, there's now "visible" / "hidden" -- you get to
> see your results on "visible" sets. There are some details
> ,
> especially regarding resubmission.
> - No "ask a question" in the platform -- only email. I presume this might
> come for next year.
> - There will be a chance to try the new platform prior to the
> qualification round, in case 27 hours isn't long enough to figure it out.
> - 4500 advance to round 2. 1000 advance to round 3. 1000 shirts.
>
> I'm really excited about the new problem type, and excited about not
> having to deal with i/o files, and about the problemsetters not being
> constrained by variable hardware anymore! Does anyone see anything I missed?
>
> Bartholomew
>
> On Tue, Mar 6, 2018 at 4:47 PM Joseph DeVincentis 
> wrote:
>
>> Registration is open and the full schedule is up.
>> https://code.google.com/codejam/
>>
>>
>> --
>> 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/CAMAzhzgTpkSGUefgy9bNVyDuLZHaB%3Dj6m1OwO7x35df4hyghgQ%40mail.gmail.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/CAHaiWHOspb9VUrD6-VapUsNZv4%2Bx90m_L%3DLjpHyrM8WTcB-cqw%40mail.gmail.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/CAGDEU-Ky69FSDJBm2NiUMKRCDm0PLFnCWVyXY%2BCYO-%2B%3DN4TtGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Re: Round 3 (aka last Online Round) of Google Code Jam just finished!

2017-06-12 Thread Xiongqi ZHANG
Agree. This should be fixed.

1. If the googlement is 1 followed by zero or more 0s, it will decay into
itself.
2. If the googlement is 0 followed by zero or more 0s, then followed by 1,
then followed by zero or more 0s, it will decay into the the googlement in
the 1st case.
3. If the googlement has at least two 1s, it will decay into a googlement
with same digit sum but with at least one digit other than 0 or 1.

eatmore 于2017年6月12日周一 上午8:29写道:

> There is an error in the analysis of problem A: "Otherwise, it must have
> at least one 1 not at the start of the googlement, so it will decay into a
> googlement with the same digit sum but with at least one digit other than 0
> or 1". This is not true. For example, googlement 010 decays into 100, which
> doesn't have any digits other than 0 or 1.
>
> --
> 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/7e6473c1-1a1a-4e83-89f9-9c091b69d082%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/CAGDEU-J5oE%2BKuuBqSFiwRExEzwo06u5zt8C60S26F-E34-qf4g%40mail.gmail.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 Xiongqi ZHANG
It feels quite awkward to have such requirement.
I guess it is due to some restriction on how Message library was
implemented.
I think these requirement should be relaxed if possible, even though we can
always pack those messages into one.


'Pablo Heiber' via Google Code Jam <google-code@googlegroups.com>于2017年6月8日周四
上午11:17写道:

> Hi,
>
> Here is the reference:
>
> "Also, you cannot send a message from node A to node B if there is already
> a message from A to B that has not been read."
>
> Last sentence of "Your submission results" section, from the quickstart
> guide: https://code.google.com/codejam/resources/quickstart-guide
>
> FWIW, the behavior of doing so is unspecified, so it might work if you
> test it, especially with small messages, but it's not guaranteed to work
> correctly every time (it may make the program crash, get a memory limit
> exceeded or a rule violation). In an actual contest, you can try doing it
> at your own risk.
>
> Best,
> Pablo
>
>
> On Thu, Jun 8, 2017 at 11:06 AM, Xiongqi ZHANG <zhangxion...@gmail.com>
> wrote:
> >
> > I didn't know the rule you mentioned either and I couldn't find the
> reference.
> > AFAIK, you should be able to send two consecutive message between the
> same pair of nodes.
> >
> > Can you cite your reference?
> >
> >
> >
> > Reynaldo Gil-Pons <gil...@gmail.com>于2017年6月8日周四 上午7:04写道:
> >>
> >> 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);

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

2017-06-08 Thread Xiongqi ZHANG
t)
> > // 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...
> > >
>

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

2017-06-04 Thread Xiongqi ZHANG
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+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.
>

-- 
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/CAGDEU-LfVCbRqRWqKd66OT%2B47S3My7Km-sTQAZ6UosugcP9T9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Thank you

2017-05-14 Thread Xiongqi ZHANG
Welcome to Google!

And technically this won't necessarily be the last round/time for you.
You can always join again once you leave Google. (Troll Face)

Bartholomew Furrow 于2017年5月14日周日 下午10:15写道:

> Congrats, Ernest! You might find Code Jam even more rewarding from the
> other side. Once you get your feet under you at Google, get in touch with
> Pablo and Ian and they'll get you started on helping out with problem prep.
> If you've got problem ideas kicking around in your head, you can submit
> those too!
>
> On Sun, May 14, 2017 at 10:31 PM Ernest Galbrun 
> wrote:
>
>> This is it for me, it was my last round, and my last time. I want to
>> warmfully thank all you guys at Google who make this possible. This
>> competition has meant a lot for me along the years. First it was a
>> motivation to learn programming, the occasion for me to dig (as deep as I
>> could) into algorithms and programming languages. And, as programming
>> became my job with the burden that comes with any job, it became a yearly
>> reminder of the ultimate fun that led me to this career.
>>
>> I never had very good results, but I always had much fun. 100 times the
>> fun even with the new distributed codejam, man this feels such an
>> accomplishment to harness the power of 100 computers and sort/count/cook a
>>  bazillion pancakes!
>>
>> This year begins a new exciting adventure for me since I will join
>> Google. This means, sadly, that I won't be allowed to compete anymore. Once
>> again, thank you.
>>
>> Finally, congratulations and good luck to all the remaining competitors,
>> you made me wonder all this years how it is even possible, and I sincerely
>> admire your skills and the effort that led you there.
>>
>> All the best,
>> Ernest (aka Hephaestos)
>>
>> --
>> --
>> Ernest Galbrun
>> 10, rue du Hameau 54136 Bouxières-aux-Dames
>> Tél : 06 28 08 60 14 / 09 73 50 81 36
>>
>> --
>> 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/CA%2B5pNgJ893mD5zOAzaTM_MSzfz7T%3DFd_YR2zoYxkoUvd8ZVndg%40mail.gmail.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/CAHaiWHP5YiRqgjeyvX%3DnJ_%3DvV8Cp8maYoChnPGfiC-bVHgjM8w%40mail.gmail.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/CAGDEU-LD81Usw0zuNaHVZNfOjwaAaiprj40bz6NSzbYVz0MEzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [gcj] Re: Problem B. Typewriter Monkey - Round 1C 2015

2017-04-24 Thread Xiongqi ZHANG
The sum should be P * (S - L + 1).

The word can only appears at S - L + 1 different locations.

> I sort of understand linearity of expectation:
> 
> "Linearity of expectation is the property that the expected value of
> the sum of random variables is equal to the sum of their individual
> expected values, regardless of whether they are independent."
> 
> But in this case individual expected value shall be P*1 for 1 banana
> per word. And hence the sum shall be P*N.
> 
> Please help me understand.
> 
> Best
> Vivek
> 
> On Tue, Apr 25, 2017 at 12:00 AM, Xiongqi ZHANG <zhangxion...@gmail.com> 
> wrote:
> > You need to learn more about linearity of expectation.
> >
> > This becomes very obvious when you understand how expectation works.
> >
> >> Hi
> >>
> >> The explanation says:
> >> "By linearity of expectation, the expected number of copies is then
> >> just P multiplied by the number of places the string can occur, which
> >> is S-L+1. This is a convenient fact to use, because we don't need to
> >> take into account that the string occurring in one position and the
> >> string occurring in an overlapping position are not independent
> >> events."
> >>
> >> I didn't understand that how come expected number of copies is P*(S-L+1).
> >>
> >> Shouldn't the min_copies be ( P*(S-L+1) )* n, where n is 1+(S-L)/(L-O)
> >> i.e. maximum number of copies that can fit in S?
> >>
> >> Please help me understand this.
> >>
> >> Best regards
> >> Vivek
> >
> > --
> > 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/5ce7851a-d6c0-423a-ac56-3b235c7fcee0%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/c97b4485-300f-4315-800a-693c6aa05736%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: Problem B. Typewriter Monkey - Round 1C 2015

2017-04-24 Thread Xiongqi ZHANG
You need to learn more about linearity of expectation.

This becomes very obvious when you understand how expectation works.

> Hi
> 
> The explanation says:
> "By linearity of expectation, the expected number of copies is then
> just P multiplied by the number of places the string can occur, which
> is S-L+1. This is a convenient fact to use, because we don't need to
> take into account that the string occurring in one position and the
> string occurring in an overlapping position are not independent
> events."
> 
> I didn't understand that how come expected number of copies is P*(S-L+1).
> 
> Shouldn't the min_copies be ( P*(S-L+1) )* n, where n is 1+(S-L)/(L-O)
> i.e. maximum number of copies that can fit in S?
> 
> Please help me understand this.
> 
> Best regards
> Vivek

-- 
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/5ce7851a-d6c0-423a-ac56-3b235c7fcee0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[gcj] Re: What stumped people in Stable Neigh-bors

2017-04-24 Thread Xiongqi ZHANG
Sometimes you are given a relative weak test cases for small.
In such cases, people get 'Correct' verdict for their small even when their 
missed some edge cases.

> I noticed only 31% correct in large attempts for Stable Neigh-bors.
> Where were the pitfalls causing so many to think they had a solution but 
> still fail somewhere, are there extra edge cases. 
> I can see many edge cases you can miss which will affect both small and large 
> but don't see edge cases exclusive to the large except the YVYV which 
> appeared in the problem statement (I would have missed it otherwise)

-- 
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/8ea62ccb-ba4c-4cac-b322-3c0041046ccf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   >