이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
vector<pair<double,double>> seg;
int n, h;
double findp(int x1, int y1, int x2, int y2){
return (x1*y2-y1*x2+x2*h-x1*h)/(y2-y1);
}
signed main(){
fastio
cin >> n >> h;
vector<pair<int,int>> v;
for(int i = 0;i < n;i++){
int x,y;
cin >> x >> y;
v.push_back({x,y});
}
for(int i = 2;i < n-1;i+=2){
seg.push_back({findp(v[i-1].first,v[i-1].second,v[i].first,v[i].second),findp(v[i].first,v[i].second,v[i+1].first,v[i+1].second)});
}
sort(seg.begin(),seg.end(),[&](pair<int,int> a, pair<int,int> b){
return a.second < b.second;
});
int lst = -1e18, ans = 0;
for(auto [a,b] : seg){
if(lst >= a) continue;
else lst = b, ans++;
}
cout << ans << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:30:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
30 | for(auto [a,b] : seg){
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |