제출 #1152327

#제출 시각아이디문제언어결과실행 시간메모리
1152327Sandarach151Odašiljači (COCI20_odasiljaci)C++17
컴파일 에러
0 ms0 KiB
#include<iostream> #include<vector> #include<tuple> using namespace std; vector<pair<long double, pair<int, int> > > vect; vector<int> sze; vector<int> lnk; int find(int a){ while(a!=lnk[a]){ a = lnk[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); } lnk[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++){ lnk.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].second-points[j].second, 2)), make_pair(i, j))); } } sort(vect.begin(), vect.end()); for(int i=0; i<vect.size(); i++){ cout << vect[i].second.first << ' ' << vect[i].second.second << ' ' << vect[i].first << '\n'; } int cnt = 0; long 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-1) 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].second-points[j].second, 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].second-points[j].second, 2)), make_pair(i, j)));
      |                                                  ^~~~
odasiljaci.cpp:51:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   51 |         sort(vect.begin(), vect.end());
      |         ^~~~
      |         short