제출 #1335617

#제출 시각아이디문제언어결과실행 시간메모리
1335617hauserlBosses (BOI16_bosses)C++20
0 / 100
1 ms344 KiB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {

    int n; scanf("%d",&n);

    vector<vector<int>> adj(n+1, vector<int>());
    vector<int> boss(n+1, -1);

    for (int i = 1; i <= n; i++) {
        int k; scanf("%d", &k);

        for (int j = 0; j < k; j++) {
            int a; scanf("%d", &a);
            adj[a].push_back(i);
        }
    }



    ll minSum = INT_MAX;

    for (int i = 1; i <= n; i++) {
        deque<pair<int, int>> q;
        vector<bool> vi(n+1, false);
        q.push_front({i, 1});

        ll sum = 0;

        while(!q.empty()) {
            auto c = q.back(); q.pop_back();
            if (vi[c.first]) continue;
            vi[c.first] = true;
            sum += c.second;

            for (const auto& v : adj[c.first]) {
                q.push_front({v, c.second + 1});
            }
        }

        if (sum < minSum) minSum = sum;
    }
   

    printf("%lld", minSum);

    return 0;
}

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

bosses.cpp: In function 'int main()':
bosses.cpp:7:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     int n; scanf("%d",&n);
      |            ~~~~~^~~~~~~~~
bosses.cpp:13:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         int k; scanf("%d", &k);
      |                ~~~~~^~~~~~~~~~
bosses.cpp:16:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |             int a; scanf("%d", &a);
      |                    ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...