제출 #1093474

#제출 시각아이디문제언어결과실행 시간메모리
1093474raphaelpBosses (BOI16_bosses)C++14
100 / 100
424 ms656 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<vector<int>> AR(N);
    for (int i = 0; i < N; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int x;
            cin >> x;
            x--;
            AR[x].push_back(i);
        }
    }
    int best = 1000000000;
    for (int root = 0; root < N; root++)
    {
        vector<int> occ(N);
        occ[root] = 1;
        int score = 0, nb = 0;
        queue<int> Q;
        Q.push(root);
        while (!Q.empty())
        {
            int x = Q.front();
            nb++;
            Q.pop();
            score += occ[x];
            for (int i = 0; i < AR[x].size(); i++)
            {
                if (occ[AR[x][i]] == 0)
                {
                    occ[AR[x][i]] = occ[x] + 1;
                    Q.push(AR[x][i]);
                }
            }
        }
        if (nb == N)
            best = min(best, score);
    }
    cout << best;
}

컴파일 시 표준 에러 (stderr) 메시지

bosses.cpp: In function 'int main()':
bosses.cpp:34:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             for (int i = 0; i < AR[x].size(); i++)
      |                             ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...