U E D R , A S I H C RSS

Jolly Jumpers/강희경

~cpp 
#include<iostream>     
using namespace std;    
    
int* InputList();    
bool Judge(int* aList);    
void OutputJudgement(bool aIsIt);    
int GetSumOfGoalGap(int aN);    
 
bool isCorrectInput; 
    
void main()    
{ 
    isCorrectInput = true; 
    OutputJudgement(Judge(InputList()));    
}    
    
int* InputList(){    
    bool isInputStart = false; 
    int numberOfInputFactor; 
    int* inputedList; 
    do{ 
        if(!isInputStart){ 
            if(cin >> numberOfInputFactor){ 
               inputedList = new int[numberOfInputFactor+1]; 
               inputedList[0] = numberOfInputFactor; 
               isInputStart = true; 
                if(numberOfInputFactor < 2){ 
                    isCorrectInput = false; 
                    numberOfInputFactor = 0; 
                } 
           } 
            else{ 
               isCorrectInput = false; 
               numberOfInputFactor = 0; 
           } 
        } 
        else{ 
            if(!(cin >> inputedList[inputedList[0] - numberOfInputFactor])){ 
               isCorrectInput = false; 
               numberOfInputFactor = 0; 
           } 
        } 
        numberOfInputFactor--; 
    }while(numberOfInputFactor >= 0); 
    char temp; 
    cin.get(temp); 
    if(temp != '\n') 
        isCorrectInput = false; 
    return inputedList; 
}    
    
bool Judge(int* aList)   
{    
    if(!isCorrectInput) 
        return false; 
    int gap;    
    bool* binaryMap = new bool[aList[0]-1];    
    for(int i = 0; i < aList[0]-1; i++)    
        binaryMap[i] = false;    
    for(i = 1; i < aList[0]; i++){    
        gap = abs(aList[i] - aList[i+1]); 
        if(gap >= aList[0] || gap == 0 || binaryMap[gap-1]){ 
            delete aList; 
            delete binaryMap; 
            return false; 
        } 
        else      
            binaryMap[gap-1] = true;       
    } 
    delete aList; 
    delete binaryMap;        
    return true;    
}    
    
void OutputJudgement(bool aIsIt)   
{    
    if(aIsIt)    
        cout << "JollyJumpers\n";    
    else    
        cout << "Nothing\n"; 
}    
 

(performance) 화하 .
2
1. gap .(ex)2 .)
  • binaryMap bool형 gap
2. gap 0 n .
: Ο(n)

2 2 3 4 2 2 3 .
2 2 3 10 JollyJumper ?? ?? --
!! ...팩토--

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:34
Processing time 0.0125 sec