Submission #373030

# Submission time Handle Problem Language Result Execution time Memory
373030 2021-03-03T05:47:45 Z sam571128 Planine (COCI21_planine) C++14
0 / 110
3 ms 876 KB
#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";
}

Compilation message

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
1 Incorrect 3 ms 876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 876 KB Output isn't correct
2 Halted 0 ms 0 KB -