Computer Science Canada

CCC Senior Filename

Author:  ultimatebuster [ Wed Feb 08, 2012 9:08 am ]
Post subject:  CCC Senior Filename

As I know, CCC Senior takes an input from a file.

How would I know what the filename is when I'm coding for solution?

Is there 1 filename for all the problems? or a different filename per problem?

Author:  mirhagk [ Wed Feb 08, 2012 10:24 am ]
Post subject:  RE:CCC Senior Filename

These will all be explained in the rules. I believe it's something like

sinput1.in

or something

Author:  crossley7 [ Wed Feb 08, 2012 5:14 pm ]
Post subject:  RE:CCC Senior Filename

s1.in
s2.in
etc.

I believe. It tells you on the contest problems what it is

Author:  mirhagk [ Wed Feb 08, 2012 9:02 pm ]
Post subject:  RE:CCC Senior Filename

Yeah crossley's ones look right. Just check the rules when you get them.

Author:  Kongaloosh [ Thu Feb 09, 2012 7:26 pm ]
Post subject:  RE:CCC Senior Filename

I'm used to using a scanner for inputs; is there a tutorial anywhere for dealing with input files?

Author:  Tony [ Thu Feb 09, 2012 7:37 pm ]
Post subject:  RE:CCC Senior Filename

You still use a Scanner. At the step where you point at STDIN, you just point at the file stream instead.

Author:  RandomLetters [ Thu Feb 09, 2012 8:02 pm ]
Post subject:  RE:CCC Senior Filename

http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Scanner.html

Quote:
As another example, this code allows long types to be assigned from entries in a file myNumbers:
code:

      Scanner sc = new Scanner(new File("myNumbers"));
      while (sc.hasNextLong()) {
          long aLong = sc.nextLong();
      }

Author:  Kongaloosh [ Thu Feb 09, 2012 11:49 pm ]
Post subject:  Re: RE:CCC Senior Filename

RandomLetters @ Thu Feb 09, 2012 7:02 pm wrote:
http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Scanner.html

Quote:
As another example, this code allows long types to be assigned from entries in a file myNumbers:
code:

      Scanner sc = new Scanner(new File("myNumbers"));
      while (sc.hasNextLong()) {
          long aLong = sc.nextLong();
      }

Thanks, that makes a lot more sense.
So, in the end, you could just cast it to a string with toString() and manipulate it that way.
What about the .out files that are in the CEMC zip folders with the example papers?
http://cemc.math.uwaterloo.ca/contests/computing/2011/index.html
Do we have to do anything with those files, or is it just to make sure that your output is consistent? Confused

Author:  Tony [ Fri Feb 10, 2012 12:02 am ]
Post subject:  RE:CCC Senior Filename

there should be no need to cast anything, as you could just scan for the next item of the expected type.

You'd probably have to write your output to a file... but, once again, you just point your output stream to a file, instead of STDOUT.

Author:  mirhagk [ Fri Feb 10, 2012 10:16 am ]
Post subject:  RE:CCC Senior Filename

your output is sn.out where n is the problem number

Author:  Angus Kong [ Mon Feb 27, 2012 2:28 am ]
Post subject:  RE:CCC Senior Filename

I'm pretty sure that all output is to screen unless it was changed this year.

Author:  crossley7 [ Mon Feb 27, 2012 8:17 am ]
Post subject:  RE:CCC Senior Filename

I know last year all of my output was to the console (from c++) but did read from a file. No need for file output

Author:  ProgrammingFun [ Mon Feb 27, 2012 6:30 pm ]
Post subject:  RE:CCC Senior Filename

Some quick help, can someone please explain how number 2 here would be solved? http://www.cemc.uwaterloo.ca/contests/computing/2010/stage1/seniorEn.pdf

This type of question stumps me every time :O

Author:  crossley7 [ Mon Feb 27, 2012 7:04 pm ]
Post subject:  RE:CCC Senior Filename

I don't think I have ever successfully coded one of these during a contest or without a lot of assistance but I believe this would be a dynamic type approach combined with some string searching from the current node where you continuously compare your current spot in the string with all possible codes and return if it works. Obviously this is a naive recursive approach, but should work at least with the restrictions they have on runtime etc.

I would love to know what a more efficient approach to the problem would be though

Author:  bbi5291 [ Mon Feb 27, 2012 7:15 pm ]
Post subject:  Re: RE:CCC Senior Filename

crossley7 @ Mon Feb 27, 2012 7:04 pm wrote:
I don't think I have ever successfully coded one of these during a contest or without a lot of assistance but I believe this would be a dynamic type approach combined with some string searching from the current node where you continuously compare your current spot in the string with all possible codes and return if it works. Obviously this is a naive recursive approach, but should work at least with the restrictions they have on runtime etc.

I would love to know what a more efficient approach to the problem would be though
It's not nearly as complex as that. You just figure out which one of the codes is a prefix of the sequence---that gives you the first letter. Then you remove that prefix and repeat---that gives you the second letter. Eventually the sequence becomes empty, and you're done. On the sample input, for example, you see that 00 is a prefix of 00000101111, so the first letter is A; remove that and get 000101111. Again, 00 is a prefix, so that's another A; remove it and get 0101111. Now 01 is a prefix, and that's B; so the third letter is B; and so on.

Author:  crossley7 [ Mon Feb 27, 2012 9:14 pm ]
Post subject:  RE:CCC Senior Filename

Oh wow, didn't notice that they weren't any ambiguity types of cases where you could have 11 and 110 for example as 2 of the letters. So in that case, it is just repeatedly checking against the keys to see if it matches the prefix like you said.

Author:  ProgrammingFun [ Mon Feb 27, 2012 9:36 pm ]
Post subject:  Re: RE:CCC Senior Filename

crossley7 @ Mon Feb 27, 2012 9:14 pm wrote:
Oh wow, didn't notice that they weren't any ambiguity types of cases where you could have 11 and 110 for example as 2 of the letters. So in that case, it is just repeatedly checking against the keys to see if it matches the prefix like you said.

As far as I understand, you can't have such a case because the test is prefix-free.


: