Page 1 of 2

10415 - Eb Alto Saxophone Player

Posted: Tue Dec 03, 2002 7:46 pm
by karl
Hi folks! :wink:

"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

Posted: Fri Dec 06, 2002 10:55 pm
by Spike
Remember to check for blank lines.

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 :P

-Moinul (AUST)

10415

Posted: Sat Jan 11, 2003 10:46 pm
by yahoo
I have tried to solve this problem several times with various algorithm but all of them give me wrong answer. Can anybody explain me the tips to solve this problem. Thanks in advance. :(

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: Fri Jan 17, 2003 9:20 am
by Larry
There are at most 200 notes in a song, and the song maybe empty.
You may want to allocate a little more memory for your string.. an array of 200 is slightly not enough.. try 210 or something. (Remember \0 and \n).

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?
:oops: :oops: :oops:
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.

8) 8) 8)
Good luck.

Posted: Wed Feb 05, 2003 11:21 am
by anupam
thank you..
you have done just like a great friend..
thaks again and waiting for any help from you everytime..
--anupam :P :P

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;
}

10415 WA need some samples

Posted: Mon May 09, 2005 5:13 am
by sunnycare

Code: Select all

//10415 Eb Alto Saxophone Player
#include <iostream>
using namespace std;
//if finger press on one button;
//then isPress[finger]=true;
bool isPress[11];
//store the number of total press of every finger
int pressNum[11];
char music[210];

void press(int finger)
{
    if(!isPress[finger])
   	{
   	    pressNum[finger]++;
   	    isPress[finger]=true;
   	}
}        
void play(char note)
{
    int i;
    //finger press part
    switch(note)
    {
    case 'c':press(10);
    case 'd':press(9);
    case 'e':press(8);
    case 'f':press(7);
    case 'g':press(4);
    case 'a':press(3);
    case 'b':press(2);break;
    case 'C':press(3);break;
    case 'D':press(9);
    case 'E':press(8);
    case 'F':press(7);
    case 'G':press(4);
    case 'A':press(3);
    case 'B':press(2);
    default:press(1);break;
    }
    //here is finger un-press part
    switch(note)
    {
    case 'b':isPress[3]=false;
    case 'a':isPress[4]=false;
    case 'g':isPress[7]=false;
    case 'f':isPress[8]=false;
    case 'e':isPress[9]=false;
    case 'd':isPress[10]=false;
    case 'c':isPress[1]=false;break;
    case 'C':
        for(i=1;i<=10;i++)
        	isPress[i]=false;
       	isPress[3]=true;
       	break;
    case 'B':isPress[3]=false;
    case 'A':isPress[4]=false;
    case 'G':isPress[7]=false;
    case 'F':isPress[8]=false;
    case 'E':isPress[9]=false;
    case 'D':isPress[10]=false;
    default:break;
    }
}            

int main(int argc,char *argv[])
{
    long n;
    long i;
    cin>>n;
    while(n-->=1)
    {
        cin>>music;
        for(i=1;i<=10;i++)
       	{
       	    isPress[i]=false;
       	    pressNum[i]=0;
       	}
        for(i=0;music[i]!='\0';i++)
        	play(music[i]);
        cout<<pressNum[1];
        for(i=2;i<=10;i++)
        	cout<<' '<<pressNum[i];
        cout<<endl;
    }
}            

Posted: Mon May 09, 2005 2:07 pm
by dumb dan
There are at most 200 notes in a song, and the song may be empty.

input:

Code: Select all

2

CbCbCb
output:

Code: Select all

0 0 0 0 0 0 0 0 0 0
0 3 3 0 0 0 0 0 0 0