PLOT1 - Plotting functions (variation)
Given a function y=f(x) in RPN-notation plot it with stars (*) and then (!) its derivation with crosses (+) for 0<=x<=20 with Δx=1 in a diagram with 21*21 points (0<=x,y<=20). Empty fields are marked with dots (.). For plotting the real number y should be rounded to integer (-0.5 -> -1, -0.4 -> 0, 0.4 -> 0, 0.5 -> 1). The function and its derivation are continuous between 0 and 20.
The function definition uses only the following characters: 0123456789x.+-*/^
'^' means 'power of'. Items are separated by space.
Input
In the first line the number N of functions, then N lines with one function.
Output
The plot of each function and its derivation in 21 lines.
Example
Input: 1
x 1 - Output: .....................
....................*
...................*.
..................*..
.................*...
................*....
...............*.....
..............*......
.............*.......
............*........
...........*.........
..........*..........
.........*...........
........*............
.......*.............
......*..............
.....*...............
....*................
...*.................
+++++++++++++++++++++
.*...................
hide comments
HWK:
2011-08-13 19:51:14
@stassats: Check the 'power' and the derivations. ;-) Last edit: 2011-08-13 20:01:45 |
|
HWK:
2011-03-21 20:47:05
Is the scoring now correct? |
|
:D:
2011-03-21 20:47:05
There seems to be some problem with the scoring. I think it is counted as challenge because of adding the score (my points don't add up). Maybe AC/Fail type would be enough here?
|
|
HWK:
2011-03-21 20:47:05
Right! "Half away from zero", that's its name.
|
|
:D:
2011-03-21 20:47:05
Yay, solved at first try :) Was expecting some rounding issues. BTW did the rounding method was supposed to be "half away from zero"? |
|
HWK:
2011-03-21 20:47:05
I've chosen the standard judge knowing that a wrong plot could be accepted. But there are a lot of tasks where this is possible and I think that this wouldn't make the solution much easier.
|
|
numerix:
2011-03-21 20:47:05
@HWK: Spaces do not matter if you use the standard judge. If the "exact judge" is used (and that's what should be done here), any character matters. As :D pointed out: Using the standard judge for this problem makes it possible to get AC even with a wrong plot. |
|
:D:
2011-03-21 20:47:05
If your're using the standard SPOJ judge and don't use any padding like dots, the testing will be very weak. For example this plot image (dots used instead of spaces for clarity):
|
|
HWK:
2011-03-21 20:47:05
In the real output data there are trailing spaces. It seems that they are lost on the website. (I've changed it.)
|
|
:D:
2011-03-21 20:47:05
In the output there are trailing whitespaces to form a rectangle, but not after the last line. What exactly is the output format?
|
Added by: | HWK |
Date: | 2011-03-02 |
Time limit: | 0.100s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |