Submission #669

# Submission time Handle Problem Language Result Execution time Memory
669 2013-03-01T03:16:28 Z pl0892029 쉬운 문제 (GA3_easy) C++
Compilation error
0 ms 0 KB
#include <grader.h>

void GetBestAnswer(int N,int *S,int K)
{
    int bucket[10][100], pos[100], top[10]={0,}, bot[10]={0,};
    int num[10]={0,1,2,3,4,5,6,7,8,9};
    int i,j,k,l,m;
    for(i=0;i<N;i++)
    bucket[S[i]][top[S[i]]++]=i, pos[i]=1;
    for(i=1;i<10;i++) for(j=i+1;j<10;j++) // quad check
        for(k=j+1;k<10;k++)for(l=k+1;l<10;l++)
        {
            if(i+j==k || i+j==l || i+k==l || j+k==l) continue;
            if(i+j+k==l) continue;
            while(K>0)
            {
            if(bot[i]==top[i] || bot[j]==top[j]) break;
            if(bot[k]==top[k] || bot[l]==top[l]) break;
            
            Mark(bucket[i][bot[i]],pos[bucket[i][bot[i]]]);
            Mark(bucket[j][bot[j]],pos[bucket[j][bot[j]]]);
            Mark(bucket[k][bot[k]],pos[bucket[k][bot[k]]]);
            Mark(bucket[l][bot[l]],pos[bucket[l][bot[l]]]);
            K--;
            m=GetScore();
            if( m==i+j+k+l ) bot[i]++, bot[j]++, bot[k]++, bot[l]++; // quad
            else if( m==i+j+k ) bot[i]++, bot[j]++, bot[k]++, pos[bucket[l][bot[l]]]++;
            else if( m==i+j+l ) bot[i]++, bot[j]++, pos[bucket[k][bot[k]]]++, bot[l]++;
            else if( m==i+k+l ) bot[i]++, pos[bucket[j][bot[j]]]++, bot[k]++, bot[l]++;
            else if( m==j+k+l ) pos[bucket[i][bot[i]]]++, bot[j]++, bot[k]++, bot[l]++; // tri
            else if( m==i+j ) bot[i]++, bot[j]++, pos[bucket[k][bot[k]]]++, pos[bucket[l][bot[l]]]++;
            else if( m==i+k ) bot[i]++, pos[bucket[j][bot[j]]]++, bot[k]++, pos[bucket[l][bot[l]]]++;
            else if( m==i+l ) bot[i]++, pos[bucket[j][bot[j]]]++, pos[bucket[k][bot[k]]]++, bot[l]++;
            else if( m==j+k ) pos[bucket[i][bot[i]]]++, bot[j]++, bot[k]++, pos[bucket[l][bot[l]]]++;
            else if( m==j+l ) pos[bucket[i][bot[i]]]++, bot[j]++, pos[bucket[k][bot[k]]]++, bot[l]++;
            else if( m==k+l ) pos[bucket[i][bot[i]]]++, pos[bucket[j][bot[j]]]++, bot[k]++, bot[l]++; // dou
            else if( m==i ) bot[i]++, pos[bucket[j][bot[j]]]++, pos[bucket[k][bot[k]]]++, pos[bucket[l][bot[l]]]++;
            else if( m==j ) pos[bucket[i][bot[i]]]++, bot[j]++, pos[bucket[k][bot[k]]]++, pos[bucket[l][bot[l]]]++;
            else if( m==k ) pos[bucket[i][bot[i]]]++, pos[bucket[j][bot[j]]]++, bot[k]++, pos[bucket[l][bot[l]]]++;
            else if( m==l ) pos[bucket[i][bot[i]]]++, pos[bucket[j][bot[j]]]++, pos[bucket[k][bot[k]]]++, bot[l]++; // sin
            else pos[bucket[i][bot[i]]]++, pos[bucket[j][bot[j]]]++, pos[bucket[k][bot[k]]]++, pos[bucket[l][bot[l]]]++; // none
            
            if(pos[bucket[i][bot[i]]]==5) bot[i]++;
            if(pos[bucket[j][bot[j]]]==5) bot[j]++;
            if(pos[bucket[k][bot[k]]]==5) bot[k]++;
            if(pos[bucket[l][bot[l]]]==5) bot[l]++;
            }
        }
        
    for(i=1;i<10;i++) for(j=i+1;j<10;j++) // tri check
        for(k=j+1;k<10;k++)
        {
            if(i+j==k) continue;
            while(K>0)
            {
            if(bot[i]==top[i] || bot[j]==top[j]) break;
            if(bot[k]==top[k]) break;
            
            Mark(bucket[i][bot[i]],pos[bucket[i][bot[i]]]);
            Mark(bucket[j][bot[j]],pos[bucket[j][bot[j]]]);
            Mark(bucket[k][bot[k]],pos[bucket[k][bot[k]]]);
            K--;
            m=GetScore();
            if( m==i+j+k ) bot[i]++, bot[j]++, bot[k]++; // tri
            else if( m==i+j ) bot[i]++, bot[j]++, pos[bucket[k][bot[k]]]++;
            else if( m==i+k ) bot[i]++, pos[bucket[j][bot[j]]]++, bot[k]++;
            else if( m==j+k ) pos[bucket[i][bot[i]]]++, bot[j]++, bot[k]++; // dou
            else if( m==i ) bot[i]++, pos[bucket[j][bot[j]]]++, pos[bucket[k][bot[k]]]++;
            else if( m==j ) pos[bucket[i][bot[i]]]++, bot[j]++, pos[bucket[k][bot[k]]]++;
            else if( m==k ) pos[bucket[i][bot[i]]]++, pos[bucket[j][bot[j]]]++, bot[k]++; // sin
            else pos[bucket[i][bot[i]]]++, pos[bucket[j][bot[j]]]++, pos[bucket[k][bot[k]]]++; // none
            
            if(pos[bucket[i][bot[i]]]==5) bot[i]++;
            if(pos[bucket[j][bot[j]]]==5) bot[j]++;
            if(pos[bucket[k][bot[k]]]==5) bot[k]++;
            }
        }
    
    for(i=1;i<10;i++) for(j=i+1;j<10;j++) // dou check
    {
        while(K>0)
        {
        if(bot[i]==top[i] || bot[j]==top[j]) break;
        
        Mark(bucket[i][bot[i]],pos[bucket[i][bot[i]]]);
        Mark(bucket[j][bot[j]],pos[bucket[j][bot[j]]]);
        K--;
        m=GetScore();
        if( m==i+j ) bot[i]++, bot[j]++; // dou
        else if( m==i ) bot[i]++, pos[bucket[j][bot[j]]]++;
        else if( m==j ) pos[bucket[i][bot[i]]]++, bot[j]++; // sin
        else pos[bucket[i][bot[i]]]++, pos[bucket[j][bot[j]]]++; // none
        
        if(pos[bucket[i][bot[i]]]==5) bot[i]++;
        if(pos[bucket[j][bot[j]]]==5) bot[j]++;
        }
    }
    
    for(i=1;i<10;i++)
    {
        while(K>0)
        {
            if(bot[i]==top[i]) break;
            Mark(bucket[i][bot[i]],pos[bucket[i][bot[i]]]);
            K--;
            m=GetScore();
            if( m==i ) bot[i]++; // sin
            else pos[bucket[i][bot[i]]]++; // none
            
            if(pos[bucket[i][bot[i]]]==5) bot[i]++;
        }
    }
    for(i=0;i<N;i++) Report(pos[i]);
}

Compilation message

grader.cpp:26:2: warning: no newline at end of file
easy.cpp:1:20: error: grader.h: No such file or directory
easy.cpp: In function 'void GetBestAnswer(int, int*, int)':
easy.cpp:20: error: 'Mark' was not declared in this scope
easy.cpp:25: error: 'GetScore' was not declared in this scope
easy.cpp:59: error: 'Mark' was not declared in this scope
easy.cpp:63: error: 'GetScore' was not declared in this scope
easy.cpp:85: error: 'Mark' was not declared in this scope
easy.cpp:88: error: 'GetScore' was not declared in this scope
easy.cpp:104: error: 'Mark' was not declared in this scope
easy.cpp:106: error: 'GetScore' was not declared in this scope
easy.cpp:113: error: 'Report' was not declared in this scope
easy.cpp:6: warning: unused variable 'num'