제출 #957691

#제출 시각아이디문제언어결과실행 시간메모리
957691OggyBosses (BOI16_bosses)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> // #define file "C:\\Users\\PC VUI\\Desktop\\CWistor\\VSCODE\\name" #define file "bosses" using namespace std; #define ll long long #define MAX 100100 #define fi first #define se second #define ull unsigned long long #define pii pair<int,int> #define pll pair<ll,ll> #define vi vector<int> #define vl vector<long long> #define mem(a, b) memset((a), (b), sizeof((a))) #define all(c) (c).begin(), (c).end() const int MOD = 1e9 + 7; const int N = 2e6 + 6; const ll M = (ll)1e18 + 7LL; const int INF = 1e9 + 7; int n, k, index = 0; vector<int> adj[N]; int vst[N]; queue<pii> q; void run_with_file() { if (fopen(file".inp", "r")) { freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout); } } int calc(int v){ q.push({v, 1}); int total = 0; vst[v] = index; while(!q.empty()){ pii x = q.front(); q.pop(); total+= x.se; for(auto u : adj[x.fi]){ if(vst[u] != index){ vst[u] = index; q.push({u, x.se + 1}); } } } for(int i = 1; i <= n; ++i){ if(vst[i] != index) return INF; } return total; } void inp(){ cin >> n >> k; for(int i = 1; i <= n; ++i){ cin >> k; for(int j = 1; j <= k; ++j){ int v; cin >> v; adj[v].push_back(i); } } int minx = INF; for(int i = 1; i <= n; ++i){ index++; minx = min(minx, calc(i)); } cout << minx; } int main() { cin.tie(0)->sync_with_stdio(0); run_with_file(); inp(); }

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

bosses.cpp:21:11: error: 'int index' redeclared as different kind of entity
   21 | int n, k, index = 0;
      |           ^~~~~
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from bosses.cpp:1:
/usr/include/strings.h:61:1: note: previous declaration 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
bosses.cpp: In function 'int calc(int)':
bosses.cpp:36:11: error: cannot resolve overloaded function 'index' based on conversion to type 'int'
   36 |  vst[v] = index;
      |           ^~~~~
bosses.cpp:41:14: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator!='
   41 |    if(vst[u] != index){
      |       ~~~~~~~^~~~~~~~
bosses.cpp:42:14: error: cannot resolve overloaded function 'index' based on conversion to type 'int'
   42 |     vst[u] = index;
      |              ^~~~~
bosses.cpp:48:13: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator!='
   48 |   if(vst[i] != index) return INF;
      |      ~~~~~~~^~~~~~~~
bosses.cpp: In function 'void inp()':
bosses.cpp:64:8: error: no post-increment operator for type
   64 |   index++;
      |        ^~
bosses.cpp: In function 'void run_with_file()':
bosses.cpp:29:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   freopen(file".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bosses.cpp:30:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   freopen(file".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~