449 - Majoring in Scales
Moderator: Board moderators
449 - Majoring in Scales - Bad Input?
The question states:
"For the purposes of this problem, we are only concerned with the following major scales: C, Db, D, Eb, E, F, Gb, G, Ab, A, Bb, and B."
However, the input contains keys which are not of this set.
The problem does not specify what to do with such keys, yet the acceptance rate is still quite high.
Does anyone know what to do for this case?
Thanks
Gilbert
"For the purposes of this problem, we are only concerned with the following major scales: C, Db, D, Eb, E, F, Gb, G, Ab, A, Bb, and B."
However, the input contains keys which are not of this set.
The problem does not specify what to do with such keys, yet the acceptance rate is still quite high.
Does anyone know what to do for this case?
Thanks
Gilbert
hI~~
Why are you sure that there are input cases that are not the scales specified?
I just solved the problem by what the problem description stated...
I just solved the problem by what the problem description stated...
-
- New poster
- Posts: 27
- Joined: Mon Nov 27, 2006 4:44 am
- Location: Indonesia
Does anyone can give me some critical I/O for my WA code?
Code: Select all
/* removed after AC */
Last edited by razor_blue on Sat Dec 02, 2006 6:20 am, edited 1 time in total.
-
- New poster
- Posts: 27
- Joined: Mon Nov 27, 2006 4:44 am
- Location: Indonesia
Does anyone can give me some critical I/O for my WA code?
Code: Select all
/* removed after AC */
Last edited by razor_blue on Sat Dec 02, 2006 6:15 am, edited 1 time in total.
Try the samples
Input:
Output:
Hope it helps.
Input:
Code: Select all
Bb
Bb UP SECOND;Bb UP THIRD;Bb UP FOURTH;Bb UP FIFTH;Bb UP SIXTH;Bb UP SEVENTH;Bb UP OCTAVE
Code: Select all
Key of Bb
Bb: UP SECOND > C
Bb: UP THIRD > D
Bb: UP FOURTH > Eb
Bb: UP FIFTH > F
Bb: UP SIXTH > G
Bb: UP SEVENTH > A
Bb: UP OCTAVE > Bb
Ami ekhono shopno dekhi...
HomePage
HomePage
-
- New poster
- Posts: 27
- Joined: Mon Nov 27, 2006 4:44 am
- Location: Indonesia
You are welcome. Use the edit option and remove your code. Thanks.
Ami ekhono shopno dekhi...
HomePage
HomePage
Hi,
it means that
is not a valid major scale-notation.
In fact the correct notation is
Cu, Erik
it means that
Code: Select all
C D Fb E# G A B C
In fact the correct notation is
Code: Select all
C D E F G A B C
Thanks for your reply, Erik. But still getting WA..
For input:
I got
Is this right ?
For input:
Code: Select all
Db
D# UP THIRD;F UP SECOND
E
F# DOWN FOURTH;Gb DOWN FOURTH
Code: Select all
Key of Db
D#: UP THIRD > F#
F: UP SECOND > Gb
Key of E
F#: DOWN FOURTH > C#
Gb: DOWN FOURTH > Db
Hello,
the major scale of Db is
Hence D# is not in the scale - for "D# UP THIRD" you have to output
Same goes for Gb in Key of E.
Cu, Erik
the major scale of Db is
Code: Select all
Db Eb F Gb Ab Bb C Db
Code: Select all
D#: invalid note for this key
Cu, Erik
-
- New poster
- Posts: 2
- Joined: Mon Dec 17, 2007 12:09 am
449 - Majoring in Scales
Why I got WA
May be I not understand this problem?
Please help me!!!!
Code: Select all
#include <stdio.h>
#include <string.h>
char list[20][2][4] =
{
{ "C", "B#" },
{ "C#", "Db" },
{ "D", "D" },
{ "D#", "Eb" },
{ "E", "Fb" },
{ "F", "E#" },
{ "F#", "Gb" },
{ "G", "G" },
{ "G#", "Ab" },
{ "A", "A" },
{ "A#", "Bb" },
{ "B", "Cb" }
};
char scale[20][4];
int find( char * );
void Build_scale( char * , int, int );
int chislo_to_int( char * );
int find_in_scale( char * );
int main()
{
char str[1000000];
char key[3];
while( gets(key) )
{
gets( str );
printf( "Key of %s\n", key );
int int_key = find( key );
Build_scale( key, int_key , 0);
int i = 0;
while( str[i] != 0 )
{
char key_in[5] = { 0, 0, 0,0};
int k = 0;
while( str[i] != ' ' ) key_in[k++] = str[i++];
key_in[k] = 0;
i++;
if( key_in[1] == '#' ) Build_scale( key, int_key , 1);
else Build_scale( key, int_key , 0);
int int_key_in = find_in_scale( key_in );
if( int_key_in == -1 )
{
printf("%s: invalid note for this key\n",key_in);
while(str[i] != ';' && str[i] != 0 ) i++;
if( str[i] != 0) i++;
continue;
}
int i_vector;
if( str[i] == 'U') i_vector = 1;
else i_vector = -1;
char vec[7]={0,0,0,0,0,0};
k = 0;
while( str[i] != ' ' ) vec[k++] = str[i++];
vec[k] = 0;
i++;
char chislo[8];
int ichislo;
k = 0;
while( str[i] != ';' && str[i] != 0 )
chislo[k++] = str[i++];
chislo[k] = 0;
if(str[i] != 0 ) i++;
ichislo = chislo_to_int( chislo );
int_key_in = int_key_in + i_vector*ichislo;
if(int_key_in < 0) int_key_in = 7 + int_key_in;
int_key_in = int_key_in %7;
printf("%s: %s %s > %s\n", key_in, vec, chislo, scale[int_key_in] );
}
printf("\n");
}
return 0;
}
int find(char *ptr)
{
for(int i = 0; i < 12; i++ )
{
if( !strcmp(ptr,list[i][0]) || !strcmp(ptr,list[i][1]) ) return i;
}
return -1;
}
void Build_scale( char *ptr, int n, int flag)
{
strcpy(scale[0], ptr);
int ms[10] = { 2,2,1,2,2,2,0,0,0 };
if( ptr[1] == 0 && flag == 0)
for(int i = 0; i < 7; i++)
{
n = ( n + ms[i] ) % 12;
if( list[n][0][1] == 0 ) strcpy( scale[i+1], list[n][0] );
else
if( list[n][0][1] == 'b' ) strcpy( scale[i+1], list[n][0] );
else strcpy( scale[i+1], list[n][1] );
}
if( ptr[1] == 0 && flag == 1 )
for(int i = 0; i < 7; i++)
{
n = ( n + ms[i] ) % 12;
if( list[n][0][1] == 0 ) strcpy( scale[i+1], list[n][0] );
else
if( list[n][0][1] == '#' ) strcpy( scale[i+1], list[n][0] );
else strcpy( scale[i+1], list[n][1] );
}
if( ptr[1] == 'b' )
for(int i = 0; i < 7; i++)
{
n = ( n + ms[i] ) % 12;
if( list[n][0][1] == 'b' ) strcpy( scale[i+1], list[n][0] );
else
if( list[n][1][1] == 'b' ) strcpy( scale[i+1], list[n][1] );
else strcpy( scale[i+1], list[n][0] );
}
if( ptr[1] == '#' )
for(int i = 0; i < 7; i++)
{
n = ( n + ms[i] ) % 12;
if( list[n][0][1] == '#' ) strcpy( scale[i+1], list[n][0] );
else
if( list[n][1][1] == '#' ) strcpy( scale[i+1], list[n][1] );
else strcpy( scale[i+1], list[n][0] );
}
}
int chislo_to_int(char *ptr)
{
if(!strncmp("SECOND" ,ptr,6)) return 1;
if(!strncmp("THIRD" ,ptr,5)) return 2;
if(!strncmp("FOURTH" ,ptr,6)) return 3;
if(!strncmp("FIFTH" ,ptr,5)) return 4;
if(!strncmp("SIXTH" ,ptr,5)) return 5;
if(!strncmp("SEVENTH" ,ptr,7)) return 6;
if(!strncmp("OCTAVE" ,ptr,6)) return 7;
return 0;
}
int find_in_scale( char *ptr)
{
for(int i = 0; i < 7; i++)
if( !strcmp( ptr, scale[i] ) ) return i;
return -1;
}
May be I not understand this problem?
Please help me!!!!