제출 #723580

#제출 시각아이디문제언어결과실행 시간메모리
723580rshohruhBosses (BOI16_bosses)C++14
0 / 100
0 ms212 KiB
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
vector<int> p;
int n;
const int inf = 1e9;
int dfs(int u){
    p[u] = 1;
    for(int v: g[u]){
        if(p[v] == -1){
            p[v] = 1;
            dfs(v);
            p[u] += p[v];
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        if(p[i] == -1) return inf;
        ans += p[i];
    }
    return ans;
}
int res(int u){
    p.assign(n+1, -1);
    return dfs(u);
}

int main(){
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    cin >> n;
    g.resize(n+1);
    for(int i = 1, k; i <= n; ++i){
        cin >> k;
        g[i].resize(k);
        for(int j = 0; j < k; ++j)
            cin >> g[i][j];
    }
    int ans = inf;
    for(int u = 1; u <= n; ++u)
        ans = min(ans, res(u));
    cout << ans;

}

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

bosses.cpp: In function 'int main()':
bosses.cpp:29:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bosses.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("output.txt", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...