Author |
Message |
ultimatebuster
|
Posted: 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
|
|
|
mirhagk
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
Posted: 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. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
RandomLetters
|
Posted: 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
|
Posted: 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? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: 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. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
mirhagk
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
|
|
|
|
crossley7
|
Posted: 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
|
Posted: 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. |
|
|
|
|
|
|