10415 - Eb Alto Saxophone Player
Posted: Tue Dec 03, 2002 7:46 pm
by karl
Hi folks!
"10415 looks very simple", I had thought until I sent my prog...
Now, I don't know, what can be checked after trying and trying.
I mentioned:
- song may be empty -> printing only '0' 10 times
- at most 200 notes in a song -> inputstring of size 300!
- first note -> all fingers required
- further notes -> only pressed, if not used in note before
- numbers seperated by single space...
I'm asking for some test cases because I have no idea what I could try now...
Best wishes
Karl
Sample Inputs
Posted: Fri Dec 13, 2002 9:42 pm
by Moinul(AUST)
This is an easy problem...
Well, Try with these inputs
------------------------------------------------------------
12
cdefgab
BAGFEDC
CbCaDCbCbCCbCbabCCbCbabae
BAAGFFEDCbabbabbbabbbabab
ccccCCdccaccacccccaaacccc
cacacaaBBBBcCbbbbBAAGGGGG
GFGFGGaaaaFFgGgGbcdefgabbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbb
cccccccccbbbbbbbbbaaaaaaaaaaa
--------------------------------------------------------------
My accepted solution returns
0 0 0 0 0 0 0 0 0 0
0 1 1 1 0 0 1 1 1 1
0 0 0 0 0 0 0 0 0 0
1 1 1 1 0 0 1 1 1 0
1 8 10 2 0 0 2 2 1 0
0 0 0 0 0 0 0 0 0 0
1 2 6 1 0 0 1 1 1 0
0 2 1 5 0 0 5 5 5 5
2 2 3 5 0 0 4 4 4 4
4 1 2 3 0 0 4 1 1 1
0 1 0 0 0 0 0 0 0 0
0 1 2 1 0 0 1 1 1 1
Hope, this Helps
-Moinul (AUST)
I have pass the all test data above .but still wrong answer?
Posted: Sun Jan 12, 2003 4:21 pm
by galois_godel
I have pass the all test data above .but still wrong answer?
#include<iostream>
#include<cstring>
using namespace std;
const int a[14][10]={
{0,1,1,1,0,0,1,1,1,1},
{0,1,1,1,0,0,1,1,1,0},
{0,1,1,1,0,0,1,1,0,0},
{0,1,1,1,0,0,1,0,0,0},
{0,1,1,1,0,0,0,0,0,0},
{0,1,1,0,0,0,0,0,0,0},
{0,1,0,0,0,0,0,0,0,0},
{0,0,1,0,0,0,0,0,0,0},
{1,1,1,1,0,0,1,1,1,0},
{1,1,1,1,0,0,1,1,0,0},
{1,1,1,1,0,0,1,0,0,0},
{1,1,1,1,0,0,0,0,0,0},
{1,1,1,0,0,0,0,0,0,0},
{1,1,0,0,0,0,0,0,0,0}};
int getindex(char c)
{
if(c>='A' && c<='G')
return (c-'C'+7)%7+7;
else
return (c-'c'+7)%7;
}
void work()
{
char note[200];
int notenum;
int i,j;
int ans[10],press[10];
cin.getline(note,200);
notenum=strlen(note);
int n;
for(i=0;i<10;i++)
{
ans=0;
press=0;
}
if(notenum==0)
{
for(i=0;i<10;i++)
if(!i)
cout<<ans;
else
cout<<" "<<ans;
cout<<endl;
return;
}
for(i=0;i<notenum;i++)
{
n=getindex(note);
for(j=0;j<10;j++)
{
if(a[n][j])
if(!press[j])
ans[j]++;
press[j]=a[n][j];
}
}
for(i=0;i<10;i++)
if(!i)
cout<<ans;
else
cout<<" "<<ans;
cout<<endl;
}
int main()
{
int t;
cin>>t;
char temp[10];
cin.getline(temp,10);
while(t--)
{
work();
}
}
Posted: Mon Jan 27, 2003 1:55 pm
by dispanser
there is no special trick or algorithm involved i think.
do the test cases from the sample input work for you?
need help
Posted: Thu Jan 30, 2003 1:48 pm
by anupam
i can't understand the problem..
that is why i can't solve this..
will anybody please tell about the problem in easy words..?
i will be greatful to him/her...
i contact yahoo but he gives me no better suggestion..
will you help?
anupam
Posted: Sun Feb 02, 2003 4:46 pm
by Ghost77 dimen
The article tells which fingers should press of each note.
So you could achieve the goal by the steps as follows.
Of course, this is just a reference, you can do it yourself.
Step 1
Declare an array or something else you like.
It keeps the messages that which positions you should press of each
note.
Step 2
As above, declare an array.
It keeps the messages that each of your fingers is pressing or relaxing.
Step 3
Also declare an array.
It keeps the messages that the pressing times of each finger.
Start with all zero.
Step 4
Then read the list of notes.
Get a note, goto Step1.
See which positions you should pressing and relaxing.
Goto Step2.
If the finger you should press, but you don't.
Then change it off to on.
Goto Step3, add the calculater to 1.
If the finger you should relax, but you don't.
Then change it on to off.
Don't touch the calculater.
Finally, if the status of your finger is the same as the request, nothing
should be done.
Do it again and again as the request.
Report to the author the number of each calculater displaying.
Good luck.
10415
Posted: Fri Jul 11, 2003 11:05 am
by boatfish
For the sample input : cdefgab
why the output is 0 1 1 1 0 0 1 1 1 1.
Because in the first note, finger 2~4, 7~10 were used; then in 2nd note(d), no finger was used; in 3rd note e, finger 2~4, 7, 8 were used. So why finger 2 is used only once?
Posted: Mon Aug 11, 2003 7:38 pm
by UFP2161
Notes: cde...
First note: c .. 2 3 4 7 8 9 10
Second note: d .. 2 3 4 7 8 9 .. 10 was released, no new fingers pressed
Third not: e .. 2 3 4 7 8 .. 9 was released, no new fingers pressed
Only increment the finger count, if it requires you to use a finger to produce the new note from the previous note.
10415 - Why Wrong Answer?
Posted: Sun Feb 20, 2005 1:49 pm
by rubendv
Hi, I have tested my program with an infinity of inputs, and it seems correct to me. However, it still evaluates to WA in the judge. Could anyone take a look at it, or send me some inputs of your one? Thanks!
#include <stdio.h>
#include <string.h>
#define MAXLENGTH (10)
#define MAXKEYS (500)
short counters[MAXLENGTH];
short usage[MAXLENGTH];
char song[MAXKEYS + 1];
void processFingers(short *list, int size){
for (int i = 0; i < size; i++)
if (usage[list - 1] == 0){
usage[list - 1] = 1;
counters[list - 1]++;
}
for (int i = MAXLENGTH; i > 0; i--)
for (int j = 0; j < MAXLENGTH; j++){
if (list[j] < i){
usage = 0;
break;
}
else if (list[j] == i)
break;
}
}
void processNote(char c){
short list[MAXLENGTH];
int counter = 0;
switch (c){
case 'c': list[counter++] = 10;
case 'd': list[counter++] = 9;
case 'e': list[counter++] = 8;
case 'f': list[counter++] = 7;
case 'g': list[counter++] = 4;
case 'a': list[counter++] = 3;
case 'b': list[counter++] = 2; break;
case 'C': list[counter++] = 3; break;
case 'D': list[counter++] = 9;
case 'E': list[counter++] = 8;
case 'F': list[counter++] = 7;
case 'G': list[counter++] = 4;
case 'A': list[counter++] = 3;
case 'B': list[counter++] = 2; list[counter++] = 1; break;
}
processFingers(list,counter);
}
void solve(void){
int size = (int)strlen(song);
for (int i = 0; i < size; i++){
processNote(song);
}
}
int main(void){
int n;
scanf("%d%*c",&n);
for (int i = 0; i < n; i++){
for (int i = 0; i < MAXLENGTH; i++){
counters = 0;
usage = 0;
}
song[0] = '\0';
gets(song);
solve();
for (int i = 0; i < MAXLENGTH - 1; i++)
printf("%d ",counters);
printf("%d\n",counters[MAXLENGTH - 1]);
}
return 0;
}