자라는 개발자/문제풀이

백준 c++ 1380 귀걸이

자란다 2022. 1. 14. 13:18
728x90
반응형

1380 귀걸이

문제 풀이

#include <bits/stdc++.h>
using namespace std;
void fast_io(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int main(void)
{
    fast_io();
    int num = 1;
    while (num)
    {
        vector<string> v;
        int arr[222] = {
            0,
        };
        int n;
        cin >> n;
        if (n == 0)
            break;
        cin.ignore();
        for (int i = 0; i < n; i++)
        {
            string str;
            getline(cin, str);
            v.push_back(str);
        }
        for (int i = 0; i < n * 2 - 1; i++)
        {
            int a;
            char c;
            cin >> a >> c;
            arr[a - 1]++;
        }
        for (int i = 0; i < n; i++)
        {
            if (arr[i] != 2)
                cout << num++ << " " << v[i] << "\n";
        }
    }
}

vs코드 자잘한 오류때문에 이유없는 디버깅을 2시간이나 했다.
돌려받지못한 학생의 명단을 출력할때 순서대로 번호를 매겨야 하는데 다른걸 출력해서 틀렸었다.

728x90
반응형