제출 #1152299

#제출 시각아이디문제언어결과실행 시간메모리
1152299Sandarach151Odašiljači (COCI20_odasiljaci)C++20
컴파일 에러
0 ms0 KiB
#include<iostream> #include<vector> #include<tuple> using namespace std; vector<pair<double, pair<int, int> > > vect; vector<int> sze; vector<int> link; int find(int a){ while(a!=link[a]){ a = link[a]; } return a; } bool same(int a, int b){ return find(a)==find(b); } void unite(int a, int b){ a = find(a); b = find(b); if(sze[a]<sze[b]){ swap(a, b); } link[b]=a; sze[a]+=sze[b]; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; pair<int, int> points[n]; sze.assign(n, 1); for(int i=0; i<n; i++){ link.push_back(i); } for(int i=0; i<n; i++){ int a, b; cin >> a >> b; points[i] = make_pair(a, b); } for(int i=0; i<n; i++){ for(int j=i+1; j<n; j++){ vect.push_back(make_pair(sqrt(pow(points[i].first-points[j].first, 2) + pow(points[i].first-points[j].first, 2)), make_pair(i, j))); } } sort(vect.begin(), vect.end()); int cnt = 0; double ans = 0; for(int i=0; i<vect.size(); i++){ int a = vect[i].second.first; int b = vect[i].second.second; if(!same(a, b)){ unite(a, b); cnt += 1; ans = vect[i].first / 2; } if(cnt==n*(n-1)/2) break; } cout << ans << '\n'; return 0; }

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

odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:48:55: error: 'pow' was not declared in this scope
   48 |                         vect.push_back(make_pair(sqrt(pow(points[i].first-points[j].first, 2) + pow(points[i].first-points[j].first, 2)), make_pair(i, j)));
      |                                                       ^~~
odasiljaci.cpp:48:50: error: 'sqrt' was not declared in this scope
   48 |                         vect.push_back(make_pair(sqrt(pow(points[i].first-points[j].first, 2) + pow(points[i].first-points[j].first, 2)), make_pair(i, j)));
      |                                                  ^~~~