JEONGLIBE 문제 오답 케이스를 못 찾아서 문의드립니다.

  • porcosedol
    porcosedol

    안녕하세요.
    이 문제를 풀기 위해서 코드는 set을 만들고 아티스트와 곡명을
    합친 문자열을 set에 넣은 뒤 set의 원소 갯수를 출력하도록 했습니다만
    예제 및 제가 만들어본 테스트 케이스 외에 어떤 케이스에
    오답이 발생하는지 며칠째 못 찾고 있어서 도움을 요청드립니다.

    코드는 폴더명, 파일 확장자, 트랙 번호를 제거하고
    아티스트와 곡명 사이에 구분자를 제거하는 것이라 단순하게 생각했는데
    애를 먹고 있습니다.

    #include <algorithm>
    #include <iostream>
    #include <string>
    #include <set>
    
    using namespace std;
    
    int main()
    {
        set<string> s;
        int test_num;
        cin >> test_num;
        cin.ignore(256, '\n');
        while (test_num) {
    
            string str;
            getline(cin, str);
            auto found = str.find_last_of("/");
    
            if (found != string::npos) {
                str = str.substr(found + 1);
            }
            found = str.rfind('.');
            str.erase(found, 4);
    
            found = str.find('.');
            if (found != string::npos) {
                str = str.substr(found + 2);
            }
    
            if (count(str.begin(), str.end(), '_') == 2) {
                found = str.find('_');
                str = str.substr(found + 1);
            }
    
            found = str.find_last_of("_");
            if (found == string::npos)
                found = str.find_last_of("-");
            auto artist = str.substr(0, found);
            auto song = str.substr(found + 1);
            if (song.at(0) == ' ')
                song.erase(0, 1);
            found = artist.find("_");
            if (found == string::npos)
                found = artist.find(".");
            if (found != string::npos)
                artist = artist.substr(found + 1);
            if (artist.at(0) == ' ')
                artist.erase(0, 1);
            if (artist.at(artist.size() - 1) == ' ')
                artist.erase(artist.size() - 1);
    
            s.insert(artist + song);
            test_num--;
        }
        cout << s.size() << endl;
        return 0;
    }
    


    9년 전
3개의 댓글이 있습니다.
  • Being
    Being

    (아티스트 명)과 (곡 제목) 비교시에 알파벳 대소문자는 구분하지 않습니다.


    9년 전 link
  • porcosedol
    porcosedol

    아 감사합니다. 문제를 꼼꼼히 읽었었으면 하고 땅을 치며.........


    9년 전 link
  • Taeyoon_Lee
    Taeyoon_Lee

    "대소문자는 구분하지 않습니다." 라는 말이 약간 모호할 수도 있겠네요...


    9년 전 link
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.