Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 CCC Senior Filename
Index -> Contests
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ultimatebuster




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
mirhagk




PostPosted: 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
crossley7




PostPosted: 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
mirhagk




PostPosted: 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.
Kongaloosh




PostPosted: 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?
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
RandomLetters




PostPosted: 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();
      }
Kongaloosh




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
mirhagk




PostPosted: Fri Feb 10, 2012 10:16 am   Post subject: RE:CCC Senior Filename

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




PostPosted: 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.
crossley7




PostPosted: 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
ProgrammingFun




PostPosted: 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
crossley7




PostPosted: 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
bbi5291




PostPosted: 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.
Display posts from previous:   
   Index -> Contests
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: